diff --git a/src/Adapter/MSTest.CoreAdapter/Discovery/UnitTestDiscoverer.cs b/src/Adapter/MSTest.CoreAdapter/Discovery/UnitTestDiscoverer.cs index 4a75207da4..b75f1f065a 100644 --- a/src/Adapter/MSTest.CoreAdapter/Discovery/UnitTestDiscoverer.cs +++ b/src/Adapter/MSTest.CoreAdapter/Discovery/UnitTestDiscoverer.cs @@ -112,7 +112,7 @@ internal void SendTestCases(string source, IEnumerable testElem var testCase = testElement.ToTestCase(); // Filter tests based on test case filters - if (filterExpression != null && filterExpression.MatchTestCase(testCase, (p) => this.TestMethodFilter.PropertyValueProvider(testCase, p)) == false) + if (filterExpression != null && !filterExpression.MatchTestCase(testCase, (p) => this.TestMethodFilter.PropertyValueProvider(testCase, p))) { continue; } diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/StackTraceHelper.cs b/src/Adapter/MSTest.CoreAdapter/Execution/StackTraceHelper.cs index 6b7fded5e5..414a21bcc5 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/StackTraceHelper.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/StackTraceHelper.cs @@ -32,9 +32,11 @@ private static List TypeToBeExcluded { if (typesToBeExcluded == null) { - typesToBeExcluded = new List(); - typesToBeExcluded.Add(typeof(Microsoft.VisualStudio.TestTools.UnitTesting.Assert).Namespace); - typesToBeExcluded.Add(typeof(MSTestExecutor).Namespace); + typesToBeExcluded = new List + { + typeof(Microsoft.VisualStudio.TestTools.UnitTesting.Assert).Namespace, + typeof(MSTestExecutor).Namespace + }; } return typesToBeExcluded; diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblyInfo.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblyInfo.cs index b197afcdaf..2c6915e869 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblyInfo.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblyInfo.cs @@ -171,10 +171,9 @@ public void RunAssemblyInitialize(TestContext testContext) var realException = this.AssemblyInitializationException.InnerException ?? this.AssemblyInitializationException; - - var outcome = UnitTestOutcome.Failed; - string errorMessage = null; - StackTraceInformation stackTraceInfo = null; + UnitTestOutcome outcome; + string errorMessage; + StackTraceInformation stackTraceInfo; if (!realException.TryGetUnitTestAssertException(out outcome, out errorMessage, out stackTraceInfo)) { var exception = realException.GetType().ToString(); diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs index ba61d7b71e..98e0ccbdfe 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestExecutionManager.cs @@ -189,7 +189,7 @@ internal void SendTestResults(TestCase test, UnitTestResult[] unitTestResults, D private static bool MatchTestFilter(ITestCaseFilterExpression filterExpression, TestCase test, TestMethodFilter testMethodFilter) { - if (filterExpression != null && filterExpression.MatchTestCase(test, p => testMethodFilter.PropertyValueProvider(test, p)) == false) + if (filterExpression != null && !filterExpression.MatchTestCase(test, p => testMethodFilter.PropertyValueProvider(test, p))) { // Skip test if not fitting filter criteria. return false; @@ -289,8 +289,8 @@ private void ExecuteTestsInSource(IEnumerable tests, IRunContext runCo // Parallel and not parallel sets. testsets = testsToRun.GroupBy(t => t.GetPropertyValue(TestAdapter.Constants.DoNotParallelizeProperty, false)); - var parallelizableTestSet = testsets.FirstOrDefault(g => g.Key == false); - var nonparallelizableTestSet = testsets.FirstOrDefault(g => g.Key == true); + var parallelizableTestSet = testsets.FirstOrDefault(g => !g.Key); + var nonparallelizableTestSet = testsets.FirstOrDefault(g => g.Key); if (parallelizableTestSet != null) { diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodInfo.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodInfo.cs index fd918bd17d..ee2b06962a 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodInfo.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodInfo.cs @@ -453,10 +453,9 @@ private Exception HandleMethodException(Exception ex, string className, string m // Get the real exception thrown by the test method Exception realException = this.GetRealException(ex); - string exceptionMessage = null; - StackTraceInformation exceptionStackTraceInfo = null; - var outcome = TestTools.UnitTesting.UnitTestOutcome.Failed; - + string exceptionMessage; + StackTraceInformation exceptionStackTraceInfo; + UTF.UnitTestOutcome outcome; if (realException.TryGetUnitTestAssertException(out outcome, out exceptionMessage, out exceptionStackTraceInfo)) { return new TestFailedException(outcome.ToUnitTestOutcome(), exceptionMessage, exceptionStackTraceInfo, realException); @@ -531,7 +530,10 @@ private void RunTestCleanupMethod(object classInstance, TestResult result) } catch (Exception ex) { - var cleanupOutcome = UTF.UnitTestOutcome.Failed; + StackTraceInformation realExceptionStackTraceInfo; + UTF.UnitTestOutcome cleanupOutcome; + string exceptionMessage; + var cleanupError = new StringBuilder(); var cleanupStackTrace = new StringBuilder(); StackTraceInformation cleanupStackTraceInfo = null; @@ -546,8 +548,6 @@ private void RunTestCleanupMethod(object classInstance, TestResult result) } Exception realException = ex.GetInnerExceptionOrDefault(); - string exceptionMessage = null; - StackTraceInformation realExceptionStackTraceInfo = null; // special case UnitTestAssertException to trim off part of the stack trace if (!realException.TryGetUnitTestAssertException(out cleanupOutcome, out exceptionMessage, out realExceptionStackTraceInfo)) @@ -632,9 +632,9 @@ private bool RunTestInitializeMethod(object classInstance, TestResult result) catch (Exception ex) { var innerException = ex.GetInnerExceptionOrDefault(); - string exceptionMessage = null; - StackTraceInformation exceptionStackTraceInfo = null; - var outcome = TestTools.UnitTesting.UnitTestOutcome.Failed; + string exceptionMessage; + StackTraceInformation exceptionStackTraceInfo; + UTF.UnitTestOutcome outcome; if (innerException.TryGetUnitTestAssertException(out outcome, out exceptionMessage, out exceptionStackTraceInfo)) { diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodRunner.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodRunner.cs index 63bc78323c..5c751ee063 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodRunner.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TestMethodRunner.cs @@ -244,9 +244,11 @@ internal UnitTestResult[] RunTestMethod() if (dataRows == null) { watch.Stop(); - var inconclusiveResult = new UTF.TestResult(); - inconclusiveResult.Outcome = UTF.UnitTestOutcome.Inconclusive; - inconclusiveResult.Duration = watch.Elapsed; + var inconclusiveResult = new UTF.TestResult + { + Outcome = UTF.UnitTestOutcome.Inconclusive, + Duration = watch.Elapsed + }; results.Add(inconclusiveResult); } else @@ -296,10 +298,12 @@ internal UnitTestResult[] RunTestMethod() catch (Exception ex) { watch.Stop(); - var failedResult = new UTF.TestResult(); - failedResult.Outcome = UTF.UnitTestOutcome.Error; - failedResult.TestFailureException = ex; - failedResult.Duration = watch.Elapsed; + var failedResult = new UTF.TestResult + { + Outcome = UTF.UnitTestOutcome.Error, + TestFailureException = ex, + Duration = watch.Elapsed + }; results.Add(failedResult); } } @@ -421,8 +425,10 @@ private UTF.UnitTestOutcome GetAggregateOutcome(List results) } // UpdatedResults contain parent result at first position and remaining results has parent info updated. - var updatedResults = new List(); - updatedResults.Add(parentResult); + var updatedResults = new List + { + parentResult + }; foreach (var result in results) { diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs b/src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs index 074845f5fc..ffbd5441df 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/TypeCache.cs @@ -100,12 +100,12 @@ public TestMethodInfo GetTestMethodInfo(TestMethod testMethod, ITestContext test { if (testMethod == null) { - throw new ArgumentNullException("testMethod"); + throw new ArgumentNullException(nameof(testMethod)); } if (testContext == null) { - throw new ArgumentNullException("testContext"); + throw new ArgumentNullException(nameof(testContext)); } // Get the classInfo (This may throw as GetType calls assembly.GetType(..,true);) @@ -682,9 +682,9 @@ private MethodInfo GetMethodInfoUsingRuntimeMethods(TestMethod testMethod, TestC { // Only find methods that match the given declaring name. testMethodInfo = - methodsInClass.Where(method => method.Name.Equals(testMethod.Name) + methodsInClass.FirstOrDefault(method => method.Name.Equals(testMethod.Name) && method.DeclaringType.FullName.Equals(testMethod.DeclaringClassFullName) - && method.HasCorrectTestMethodSignature(true)).FirstOrDefault(); + && method.HasCorrectTestMethodSignature(true)); } else { diff --git a/src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs b/src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs index 679d5a8971..597e2a6ca8 100644 --- a/src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs +++ b/src/Adapter/MSTest.CoreAdapter/Execution/UnitTestRunner.cs @@ -68,7 +68,7 @@ internal UnitTestResult[] RunSingleTest(TestMethod testMethod, IDictionaryThe adapter's UnitTestOutcome object. public static UnitTestOutcome ToUnitTestOutcome(this UTF.UnitTestOutcome frameworkTestOutcome) { - UnitTestOutcome outcome = UnitTestOutcome.Passed; + UnitTestOutcome outcome; switch (frameworkTestOutcome) { diff --git a/src/Adapter/MSTest.CoreAdapter/Helpers/RunSettingsUtilities.cs b/src/Adapter/MSTest.CoreAdapter/Helpers/RunSettingsUtilities.cs index d5ebb0db98..f3d52842ab 100644 --- a/src/Adapter/MSTest.CoreAdapter/Helpers/RunSettingsUtilities.cs +++ b/src/Adapter/MSTest.CoreAdapter/Helpers/RunSettingsUtilities.cs @@ -22,9 +22,11 @@ internal static XmlReaderSettings ReaderSettings { get { - var settings = new XmlReaderSettings(); - settings.IgnoreComments = true; - settings.IgnoreWhitespace = true; + var settings = new XmlReaderSettings + { + IgnoreComments = true, + IgnoreWhitespace = true + }; return settings; } } diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs index b9b8d13bce..57dd788905 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs @@ -26,7 +26,7 @@ public UnitTestElement(TestMethod testMethod) { if (testMethod == null) { - throw new ArgumentNullException("testMethod"); + throw new ArgumentNullException(nameof(testMethod)); } Debug.Assert(testMethod.FullClassName != null, "Full className cannot be empty"); @@ -115,8 +115,10 @@ internal TestCase ToTestCase() // : string.Format(CultureInfo.InvariantCulture, "{0}.{1}", this.TestMethod.FullClassName, this.TestMethod.Name); var fullName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", this.TestMethod.FullClassName, this.TestMethod.Name); - TestCase testCase = new TestCase(fullName, TestAdapter.Constants.ExecutorUri, this.TestMethod.AssemblyName); - testCase.DisplayName = this.GetDisplayName(); + TestCase testCase = new TestCase(fullName, TestAdapter.Constants.ExecutorUri, this.TestMethod.AssemblyName) + { + DisplayName = string.IsNullOrEmpty(this.DisplayName) ? this.TestMethod.Name : this.DisplayName + }; if (this.TestMethod.HasManagedMethodAndTypeProperties) { diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestOutcome.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestOutcome.cs index eb70a80dff..cabf3c7683 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestOutcome.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestOutcome.cs @@ -6,7 +6,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel /// /// Outcome of a test /// - public enum UnitTestOutcome : int + public enum UnitTestOutcome { /// /// There was a system error while we were trying to execute a test. diff --git a/src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs b/src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs index afc795f50d..ec491ab5c7 100644 --- a/src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs +++ b/src/Adapter/MSTest.CoreAdapter/TestMethodFilter.cs @@ -82,14 +82,9 @@ internal object PropertyValueProvider(TestCase currentTest, string propertyName) if (currentTest != null && propertyName != null) { TestProperty testProperty; - if (this.supportedProperties.TryGetValue(propertyName, out testProperty)) + if (this.supportedProperties.TryGetValue(propertyName, out testProperty) && currentTest.Properties.Contains(testProperty)) { - // Test case might not have defined this property. In that case GetPropertyValue() - // would return default value. For filtering, if property is not defined return null. - if (currentTest.Properties.Contains(testProperty)) - { - return currentTest.GetPropertyValue(testProperty); - } + return currentTest.GetPropertyValue(testProperty); } } diff --git a/src/Adapter/PlatformServices.Desktop/AssemblyResolver.cs b/src/Adapter/PlatformServices.Desktop/AssemblyResolver.cs index 96c6262c50..3e09a41b5f 100644 --- a/src/Adapter/PlatformServices.Desktop/AssemblyResolver.cs +++ b/src/Adapter/PlatformServices.Desktop/AssemblyResolver.cs @@ -81,7 +81,7 @@ public AssemblyResolver(IList directories) { if (directories == null || directories.Count == 0) { - throw new ArgumentNullException("directories"); + throw new ArgumentNullException(nameof(directories)); } this.searchDirectories = new List(directories); diff --git a/src/Adapter/PlatformServices.Desktop/Data/CsvDataConnection.cs b/src/Adapter/PlatformServices.Desktop/Data/CsvDataConnection.cs index 9972c24dbe..3fdfb6aa94 100644 --- a/src/Adapter/PlatformServices.Desktop/Data/CsvDataConnection.cs +++ b/src/Adapter/PlatformServices.Desktop/Data/CsvDataConnection.cs @@ -44,8 +44,10 @@ private string TableName public override List GetDataTablesAndViews() { - List tableNames = new List(1); - tableNames.Add(this.TableName); + List tableNames = new List(1) + { + this.TableName + }; return tableNames; } @@ -155,8 +157,10 @@ public DataTable ReadTable(string tableName, IEnumerable columns, int maxRows) dataAdapter.SelectCommand = command; - DataTable table = new DataTable(); - table.Locale = CultureInfo.InvariantCulture; + DataTable table = new DataTable + { + Locale = CultureInfo.InvariantCulture + }; dataAdapter.Fill(table); return table; } diff --git a/src/Adapter/PlatformServices.Desktop/Data/OdbcDataConnection.cs b/src/Adapter/PlatformServices.Desktop/Data/OdbcDataConnection.cs index 6280c485bb..13af29c8ff 100644 --- a/src/Adapter/PlatformServices.Desktop/Data/OdbcDataConnection.cs +++ b/src/Adapter/PlatformServices.Desktop/Data/OdbcDataConnection.cs @@ -21,7 +21,7 @@ public OdbcDataConnection(string invariantProviderName, string connectionString, // Need open connection to get Connection.Driver. Debug.Assert(this.IsOpen(), "The connection must be open!"); - this.isMSSql = this.Connection != null ? IsMSSql(this.Connection.Driver) : false; + this.isMSSql = this.Connection != null && IsMSSql(this.Connection.Driver); } public new OdbcCommandBuilder CommandBuilder diff --git a/src/Adapter/PlatformServices.Desktop/Data/OleDataConnection.cs b/src/Adapter/PlatformServices.Desktop/Data/OleDataConnection.cs index e4019c8777..35c4fcb89b 100644 --- a/src/Adapter/PlatformServices.Desktop/Data/OleDataConnection.cs +++ b/src/Adapter/PlatformServices.Desktop/Data/OleDataConnection.cs @@ -23,7 +23,7 @@ public OleDataConnection(string invariantProviderName, string connectionString, Debug.Assert(this.IsOpen(), "The connection must be open!"); // Fill m_isMSSql. - this.isMSSql = this.Connection != null ? IsMSSql(this.Connection.Provider) : false; + this.isMSSql = this.Connection != null && IsMSSql(this.Connection.Provider); } public new OleDbCommandBuilder CommandBuilder diff --git a/src/Adapter/PlatformServices.Desktop/Data/TestDataConnection.cs b/src/Adapter/PlatformServices.Desktop/Data/TestDataConnection.cs index 7baa356ace..542309c636 100644 --- a/src/Adapter/PlatformServices.Desktop/Data/TestDataConnection.cs +++ b/src/Adapter/PlatformServices.Desktop/Data/TestDataConnection.cs @@ -96,12 +96,9 @@ public virtual void Dispose() internal static bool PathNeedsFixup(string path) { - if (!string.IsNullOrEmpty(path)) + if (!string.IsNullOrEmpty(path) && path.StartsWith(ConnectionDirectoryKey, StringComparison.Ordinal)) { - if (path.StartsWith(ConnectionDirectoryKey, StringComparison.Ordinal)) - { - return true; - } + return true; } return false; diff --git a/src/Adapter/PlatformServices.Desktop/Data/TestDataConnectionSql.cs b/src/Adapter/PlatformServices.Desktop/Data/TestDataConnectionSql.cs index 0593e22fcf..c0791af865 100644 --- a/src/Adapter/PlatformServices.Desktop/Data/TestDataConnectionSql.cs +++ b/src/Adapter/PlatformServices.Desktop/Data/TestDataConnectionSql.cs @@ -443,7 +443,7 @@ private int FindIdentifierEnd(string text, int start) } // Skip the quote we just found - here = here + 1; + here += 1; // If this the end? if (here == end || text[here] != suffixChar) @@ -453,7 +453,7 @@ private int FindIdentifierEnd(string text, int start) } // We have a double quote, skip the second one, then keep looking - here = here + 1; + here += 1; } // If we fall off end of loop, @@ -533,18 +533,15 @@ public override List GetDataTablesAndViews() bool isDefaultSchema = false; // Check the table type for validity - if (metadata.TableTypeColumn != null) + if (metadata.TableTypeColumn != null && row[metadata.TableTypeColumn] != DBNull.Value) { - if (row[metadata.TableTypeColumn] != DBNull.Value) + string tableType = row[metadata.TableTypeColumn] as string; + if (!IsInArray(tableType, metadata.ValidTableTypes)) { - string tableType = row[metadata.TableTypeColumn] as string; - if (!IsInArray(tableType, metadata.ValidTableTypes)) - { - WriteDiagnostics("Table type {0} is not acceptable", tableType); - - // Not a valid table type, get the next row - continue; - } + WriteDiagnostics("Table type {0} is not acceptable", tableType); + + // Not a valid table type, get the next row + continue; } } @@ -728,7 +725,7 @@ private static bool IsInArray(string candidate, string[] values) public bool IsOpen() #pragma warning restore SA1202 // Elements must be ordered by access { - return this.connection != null ? this.connection.State == ConnectionState.Open : false; + return this.connection != null && this.connection.State == ConnectionState.Open; } /// @@ -843,8 +840,10 @@ public override DataTable ReadTable(string tableName, IEnumerable columns) WriteDiagnostics("ReadTable: SQL Query: {0}", command.CommandText); dataAdapter.SelectCommand = command; - DataTable table = new DataTable(); - table.Locale = CultureInfo.InvariantCulture; + DataTable table = new DataTable + { + Locale = CultureInfo.InvariantCulture + }; dataAdapter.Fill(table); table.TableName = tableName; // Make table name in the data set the same as original table name. diff --git a/src/Adapter/PlatformServices.Desktop/Data/XmlDataConnection.cs b/src/Adapter/PlatformServices.Desktop/Data/XmlDataConnection.cs index fe5ad50af1..9e95e11a32 100644 --- a/src/Adapter/PlatformServices.Desktop/Data/XmlDataConnection.cs +++ b/src/Adapter/PlatformServices.Desktop/Data/XmlDataConnection.cs @@ -86,7 +86,7 @@ public override DataTable ReadTable(string tableName, IEnumerable columns) // once for every table in it. Oh well. Reading XML is pretty quick // compared to other forms of data source DataSet ds = this.LoadDataSet(false); - return ds != null ? ds.Tables[tableName] : null; + return ds?.Tables[tableName]; } [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Requirement is to handle all kinds of user exceptions and message appropriately.")] @@ -95,8 +95,10 @@ private DataSet LoadDataSet(bool schemaOnly) { try { - DataSet dataSet = new DataSet(); - dataSet.Locale = CultureInfo.CurrentCulture; + DataSet dataSet = new DataSet + { + Locale = CultureInfo.CurrentCulture + }; string path = this.FixPath(this.fileName) ?? Path.GetFullPath(this.fileName); if (schemaOnly) { diff --git a/src/Adapter/PlatformServices.Desktop/Deployment/AssemblyLoadWorker.cs b/src/Adapter/PlatformServices.Desktop/Deployment/AssemblyLoadWorker.cs index 41db44b578..25d05f629c 100644 --- a/src/Adapter/PlatformServices.Desktop/Deployment/AssemblyLoadWorker.cs +++ b/src/Adapter/PlatformServices.Desktop/Deployment/AssemblyLoadWorker.cs @@ -43,7 +43,7 @@ public string[] GetFullPathToDependentAssemblies(string assemblyPath, out IList< Debug.Assert(!string.IsNullOrEmpty(assemblyPath), "assemblyPath"); warnings = new List(); - Assembly assembly = null; + Assembly assembly; try { // First time we load in LoadFromContext to avoid issues. @@ -58,9 +58,10 @@ public string[] GetFullPathToDependentAssemblies(string assemblyPath, out IList< Debug.Assert(assembly != null, "assembly"); List result = new List(); - List visitedAssemblies = new List(); - - visitedAssemblies.Add(assembly.FullName); + List visitedAssemblies = new List + { + assembly.FullName + }; this.ProcessChildren(assembly, result, visitedAssemblies, warnings); @@ -230,7 +231,7 @@ private void GetDependentAssembliesInternal(string assemblyString, IList visitedAssemblies.Add(assemblyString); - Assembly assembly = null; + Assembly assembly; try { string postPolicyAssembly = AppDomain.CurrentDomain.ApplyPolicy(assemblyString); diff --git a/src/Adapter/PlatformServices.Desktop/Services/DesktopTestContextImplementation.cs b/src/Adapter/PlatformServices.Desktop/Services/DesktopTestContextImplementation.cs index 7d7245bde1..db3cd4f1dd 100644 --- a/src/Adapter/PlatformServices.Desktop/Services/DesktopTestContextImplementation.cs +++ b/src/Adapter/PlatformServices.Desktop/Services/DesktopTestContextImplementation.cs @@ -250,7 +250,7 @@ public override void AddResultFile(string fileName) { if (string.IsNullOrEmpty(fileName)) { - throw new ArgumentException(Resource.Common_CannotBeNullOrEmpty, "fileName"); + throw new ArgumentException(Resource.Common_CannotBeNullOrEmpty, nameof(fileName)); } this.testResultFiles.Add(Path.GetFullPath(fileName)); @@ -427,7 +427,7 @@ public void AddProperty(string propertyName, string propertyValue) /// Results files generated in run. public IList GetResultFiles() { - if (this.testResultFiles.Count() == 0) + if (!this.testResultFiles.Any()) { return null; } @@ -490,7 +490,7 @@ private static UTF.UnitTestOutcome ToUTF(UTF.UnitTestOutcome outcome) /// Property value private string GetStringPropertyValue(string propertyName) { - object propertyValue = null; + object propertyValue; this.properties.TryGetValue(propertyName, out propertyValue); return propertyValue as string; } diff --git a/src/Adapter/PlatformServices.Desktop/Services/DesktopTestDataSource.cs b/src/Adapter/PlatformServices.Desktop/Services/DesktopTestDataSource.cs index 20a4d589b5..bf94dcf3be 100644 --- a/src/Adapter/PlatformServices.Desktop/Services/DesktopTestDataSource.cs +++ b/src/Adapter/PlatformServices.Desktop/Services/DesktopTestDataSource.cs @@ -32,8 +32,10 @@ public IEnumerable GetData(UTF.ITestMethod testMethodInfo, ITestContext { // Figure out where (as well as the current directory) we could look for data files // for unit tests this means looking at the location of the test itself - List dataFolders = new List(); - dataFolders.Add(Path.GetDirectoryName(new Uri(testMethodInfo.MethodInfo.Module.Assembly.CodeBase).LocalPath)); + List dataFolders = new List + { + Path.GetDirectoryName(new Uri(testMethodInfo.MethodInfo.Module.Assembly.CodeBase).LocalPath) + }; List dataRowResults = new List(); @@ -120,7 +122,7 @@ private IEnumerable GetPermutation(UTF.DataAccessMethod dataAccessMethod, i /// The data access method. private void GetConnectionProperties(UTF.DataSourceAttribute dataSourceAttribute, out string providerNameInvariant, out string connectionString, out string tableName, out UTF.DataAccessMethod dataAccessMethod) { - if (string.IsNullOrEmpty(dataSourceAttribute.DataSourceSettingName) == false) + if (!string.IsNullOrEmpty(dataSourceAttribute.DataSourceSettingName)) { UTF.DataSourceElement elem = UTF.TestConfiguration.ConfigurationSection.DataSources[dataSourceAttribute.DataSourceSettingName]; if (elem == null) diff --git a/src/Adapter/PlatformServices.Desktop/Services/DesktopTestSource.cs b/src/Adapter/PlatformServices.Desktop/Services/DesktopTestSource.cs index f00b3095e3..ec86ae8bc9 100644 --- a/src/Adapter/PlatformServices.Desktop/Services/DesktopTestSource.cs +++ b/src/Adapter/PlatformServices.Desktop/Services/DesktopTestSource.cs @@ -47,7 +47,7 @@ public bool IsAssemblyReferenced(AssemblyName assemblyName, string source) bool? utfReference = AssemblyHelper.DoesReferencesAssembly(source, assemblyName); // If no reference to UTF don't run discovery. Take conservative approach. If not able to find proceed with discovery. - if (utfReference.HasValue && utfReference.Value == false) + if (utfReference.HasValue && !utfReference.Value) { return false; } diff --git a/src/Adapter/PlatformServices.Desktop/Services/DesktopTestSourceHost.cs b/src/Adapter/PlatformServices.Desktop/Services/DesktopTestSourceHost.cs index 227d338194..e7c9928fd4 100644 --- a/src/Adapter/PlatformServices.Desktop/Services/DesktopTestSourceHost.cs +++ b/src/Adapter/PlatformServices.Desktop/Services/DesktopTestSourceHost.cs @@ -246,10 +246,11 @@ internal string GetAppBaseAsPerPlatform() /// internal virtual List GetResolutionPaths(string sourceFileName, bool isPortableMode) { - List resolutionPaths = new List(); - - // Add path of test assembly in resolution path. Mostly will be used for resolving winmd. - resolutionPaths.Add(Path.GetDirectoryName(sourceFileName)); + List resolutionPaths = new List + { + // Add path of test assembly in resolution path. Mostly will be used for resolving winmd. + Path.GetDirectoryName(sourceFileName) + }; if (!isPortableMode) { diff --git a/src/Adapter/PlatformServices.Desktop/Utilities/AppDomainUtilities.cs b/src/Adapter/PlatformServices.Desktop/Utilities/AppDomainUtilities.cs index 7be4ff734c..f75880a87c 100644 --- a/src/Adapter/PlatformServices.Desktop/Utilities/AppDomainUtilities.cs +++ b/src/Adapter/PlatformServices.Desktop/Utilities/AppDomainUtilities.cs @@ -78,9 +78,10 @@ internal static void SetAppDomainFrameworkVersionBasedOnTestSource(AppDomainSetu [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")] internal static string GetTargetFrameworkVersionString(string testSourcePath) { - AppDomainSetup appDomainSetup = new AppDomainSetup(); - - appDomainSetup.LoaderOptimization = LoaderOptimization.MultiDomainHost; + AppDomainSetup appDomainSetup = new AppDomainSetup + { + LoaderOptimization = LoaderOptimization.MultiDomainHost + }; AppDomainUtilities.SetConfigurationFile(appDomainSetup, new DeploymentUtility().GetConfigFile(testSourcePath)); diff --git a/src/Adapter/PlatformServices.Desktop/Utilities/DesktopAssemblyUtility.cs b/src/Adapter/PlatformServices.Desktop/Utilities/DesktopAssemblyUtility.cs index 006849bce7..1c98690ba4 100644 --- a/src/Adapter/PlatformServices.Desktop/Utilities/DesktopAssemblyUtility.cs +++ b/src/Adapter/PlatformServices.Desktop/Utilities/DesktopAssemblyUtility.cs @@ -189,8 +189,10 @@ internal virtual string[] GetFullPathToDependentAssemblies(string assemblyPath, EqtTrace.InfoIf(EqtTrace.IsInfoEnabled, "AssemblyDependencyFinder.GetDependentAssemblies: start."); - AppDomainSetup setupInfo = new AppDomainSetup(); - setupInfo.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(assemblyPath)); + AppDomainSetup setupInfo = new AppDomainSetup + { + ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(assemblyPath)) + }; Debug.Assert(string.IsNullOrEmpty(configFile) || File.Exists(configFile), "Config file is specified but does not exist: {0}", configFile); diff --git a/src/Adapter/PlatformServices.Desktop/Utilities/DesktopReflectionUtility.cs b/src/Adapter/PlatformServices.Desktop/Utilities/DesktopReflectionUtility.cs index 5cce3d9a3f..7bd0c629cd 100644 --- a/src/Adapter/PlatformServices.Desktop/Utilities/DesktopReflectionUtility.cs +++ b/src/Adapter/PlatformServices.Desktop/Utilities/DesktopReflectionUtility.cs @@ -108,14 +108,11 @@ internal object[] GetCustomAttributes(MemberInfo memberInfo, Type type, bool inh nonUniqueAttributes); var baseDefinition = tempMethodInfo.GetBaseDefinition(); - if (baseDefinition != null) - { - if (string.Equals( + if (baseDefinition != null && string.Equals( string.Concat(tempMethodInfo.DeclaringType.FullName, tempMethodInfo.Name), string.Concat(baseDefinition.DeclaringType.FullName, baseDefinition.Name))) - { - break; - } + { + break; } tempMethodInfo = baseDefinition; diff --git a/src/Adapter/PlatformServices.Desktop/Utilities/RandomIntPermutation.cs b/src/Adapter/PlatformServices.Desktop/Utilities/RandomIntPermutation.cs index 56b2ffd83b..9b713cc486 100644 --- a/src/Adapter/PlatformServices.Desktop/Utilities/RandomIntPermutation.cs +++ b/src/Adapter/PlatformServices.Desktop/Utilities/RandomIntPermutation.cs @@ -19,7 +19,7 @@ public RandomIntPermutation(int numberOfObjects) { if (numberOfObjects < 0) { - throw new ArgumentException(Resource.WrongNumberOfObjects, "numberOfObjects"); + throw new ArgumentException(Resource.WrongNumberOfObjects, nameof(numberOfObjects)); } this.objects = new int[numberOfObjects]; diff --git a/src/Adapter/PlatformServices.Desktop/Utilities/SequentialIntPermutation.cs b/src/Adapter/PlatformServices.Desktop/Utilities/SequentialIntPermutation.cs index 7d345e7e0b..921c4e5cf8 100644 --- a/src/Adapter/PlatformServices.Desktop/Utilities/SequentialIntPermutation.cs +++ b/src/Adapter/PlatformServices.Desktop/Utilities/SequentialIntPermutation.cs @@ -19,7 +19,7 @@ public SequentialIntPermutation(int numberOfObjects) { if (numberOfObjects < 0) { - throw new ArgumentException(Resource.WrongNumberOfObjects, "numberOfObjects"); + throw new ArgumentException(Resource.WrongNumberOfObjects, nameof(numberOfObjects)); } this.numberOfObjects = numberOfObjects; diff --git a/src/Adapter/PlatformServices.Desktop/Utilities/XmlUtilities.cs b/src/Adapter/PlatformServices.Desktop/Utilities/XmlUtilities.cs index 6d5d829f34..5a0871cdd7 100644 --- a/src/Adapter/PlatformServices.Desktop/Utilities/XmlUtilities.cs +++ b/src/Adapter/PlatformServices.Desktop/Utilities/XmlUtilities.cs @@ -109,7 +109,7 @@ private static void AddAssemblyBindingRedirect( Debug.Assert(assemblyName != null, "assemblyName should not be null."); if (assemblyName == null) { - throw new ArgumentNullException("assemblyName"); + throw new ArgumentNullException(nameof(assemblyName)); } // Convert the public key token into a string. diff --git a/src/Adapter/PlatformServices.NetCore/Services/NetCoreTestContextImplementation.cs b/src/Adapter/PlatformServices.NetCore/Services/NetCoreTestContextImplementation.cs index 23eeebd7d2..068d458c5d 100644 --- a/src/Adapter/PlatformServices.NetCore/Services/NetCoreTestContextImplementation.cs +++ b/src/Adapter/PlatformServices.NetCore/Services/NetCoreTestContextImplementation.cs @@ -226,7 +226,7 @@ public override void AddResultFile(string fileName) { if (string.IsNullOrEmpty(fileName)) { - throw new ArgumentException(Resource.Common_CannotBeNullOrEmpty, "fileName"); + throw new ArgumentException(Resource.Common_CannotBeNullOrEmpty, nameof(fileName)); } this.testResultFiles.Add(Path.GetFullPath(fileName)); @@ -422,7 +422,7 @@ public void SetDataConnection(object dbConnection) /// Property value private object GetPropertyValue(string propertyName) { - object propertyValue = null; + object propertyValue; this.properties.TryGetValue(propertyName, out propertyValue); return propertyValue; @@ -435,7 +435,7 @@ private object GetPropertyValue(string propertyName) /// Property value private string GetStringPropertyValue(string propertyName) { - object propertyValue = null; + object propertyValue; this.properties.TryGetValue(propertyName, out propertyValue); return propertyValue as string; } diff --git a/src/Adapter/PlatformServices.Shared/netstandard1.0/Services/ns10TestContextImplementation.cs b/src/Adapter/PlatformServices.Shared/netstandard1.0/Services/ns10TestContextImplementation.cs index b444ccb6b2..4a35764f26 100644 --- a/src/Adapter/PlatformServices.Shared/netstandard1.0/Services/ns10TestContextImplementation.cs +++ b/src/Adapter/PlatformServices.Shared/netstandard1.0/Services/ns10TestContextImplementation.cs @@ -329,7 +329,7 @@ public void SetDataConnection(object dbConnection) /// Property value private object GetPropertyValue(string propertyName) { - object propertyValue = null; + object propertyValue; this.properties.TryGetValue(propertyName, out propertyValue); return propertyValue; diff --git a/src/Adapter/PlatformServices.Shared/netstandard1.3/Services/ns13TestDeployment.cs b/src/Adapter/PlatformServices.Shared/netstandard1.3/Services/ns13TestDeployment.cs index 6a66d03ddc..fbfd7f669b 100644 --- a/src/Adapter/PlatformServices.Shared/netstandard1.3/Services/ns13TestDeployment.cs +++ b/src/Adapter/PlatformServices.Shared/netstandard1.3/Services/ns13TestDeployment.cs @@ -15,7 +15,9 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; +#if !NETSTANDARD1_5 using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; +#endif /// /// The test deployment. diff --git a/src/Adapter/PlatformServices.Shared/netstandard1.3/Utilities/ns13DeploymentUtilityBase.cs b/src/Adapter/PlatformServices.Shared/netstandard1.3/Utilities/ns13DeploymentUtilityBase.cs index cfdf441016..47b3277a6a 100644 --- a/src/Adapter/PlatformServices.Shared/netstandard1.3/Utilities/ns13DeploymentUtilityBase.cs +++ b/src/Adapter/PlatformServices.Shared/netstandard1.3/Utilities/ns13DeploymentUtilityBase.cs @@ -180,8 +180,10 @@ protected IEnumerable Deploy(IList deploymentItems, stri Debug.Assert(Path.IsPathRooted(deploymentItemFile), "File " + deploymentItemFile + " is not rooted"); // List of files to deploy, by default, just itemFile. - var filesToDeploy = new List(1); - filesToDeploy.Add(deploymentItemFile); + var filesToDeploy = new List(1) + { + deploymentItemFile + }; // Find dependencies of test deployment items and deploy them at the same time as master file. if (deploymentItem.OriginType == DeploymentItemOriginType.PerTestDeployment && @@ -390,7 +392,7 @@ protected string AddTestSourceConfigFileIfExists(string testSource, IList diff --git a/src/TestFramework/Extension.Desktop/ConfigurationSettings/TestConfigurationSection.cs b/src/TestFramework/Extension.Desktop/ConfigurationSettings/TestConfigurationSection.cs index c92bed8d4f..d3fdb9bebe 100644 --- a/src/TestFramework/Extension.Desktop/ConfigurationSettings/TestConfigurationSection.cs +++ b/src/TestFramework/Extension.Desktop/ConfigurationSettings/TestConfigurationSection.cs @@ -15,8 +15,10 @@ public sealed class TestConfigurationSection : ConfigurationSection static TestConfigurationSection() { - properties = new ConfigurationPropertyCollection(); - properties.Add(DataSourcesValue); + properties = new ConfigurationPropertyCollection + { + DataSourcesValue + }; } /// diff --git a/src/TestFramework/Extension.Desktop/PrivateObject.cs b/src/TestFramework/Extension.Desktop/PrivateObject.cs index a6c656affc..959b551de0 100644 --- a/src/TestFramework/Extension.Desktop/PrivateObject.cs +++ b/src/TestFramework/Extension.Desktop/PrivateObject.cs @@ -837,7 +837,7 @@ private LinkedList GetMethodCandidates(string methodName, Type[] par Debug.Assert(typeArguments != null, "typeArguments should not be null."); LinkedList methodCandidates = new LinkedList(); - LinkedList methods = null; + LinkedList methods; if (!this.GenericMethodCache.TryGetValue(methodName, out methods)) { @@ -849,10 +849,8 @@ private LinkedList GetMethodCandidates(string methodName, Type[] par foreach (MethodInfo candidate in methods) { bool paramMatch = true; - ParameterInfo[] candidateParams = null; + ParameterInfo[] candidateParams; Type[] genericArgs = candidate.GetGenericArguments(); - Type sourceParameterType = null; - if (genericArgs.Length != typeArguments.Length) { continue; @@ -875,8 +873,7 @@ private LinkedList GetMethodCandidates(string methodName, Type[] par foreach (ParameterInfo candidateParam in candidateParams) { - sourceParameterType = parameterTypes[i++]; - + Type sourceParameterType = parameterTypes[i++]; if (candidateParam.ParameterType.ContainsGenericParameters) { // Since we have a generic parameter here, just make sure the IsArray matches. diff --git a/src/TestFramework/Extension.Desktop/PrivateType.cs b/src/TestFramework/Extension.Desktop/PrivateType.cs index 413ff1cba3..2cb5c15d89 100644 --- a/src/TestFramework/Extension.Desktop/PrivateType.cs +++ b/src/TestFramework/Extension.Desktop/PrivateType.cs @@ -46,12 +46,7 @@ public PrivateType(string assemblyName, string typeName) /// The wrapped Type to create. public PrivateType(Type type) { - if (type == null) - { - throw new ArgumentNullException("type"); - } - - this.type = type; + this.type = type ?? throw new ArgumentNullException(nameof(type)); } /// diff --git a/src/TestFramework/Extension.Desktop/RuntimeTypeHelper.cs b/src/TestFramework/Extension.Desktop/RuntimeTypeHelper.cs index 987a27cf94..42ba128220 100644 --- a/src/TestFramework/Extension.Desktop/RuntimeTypeHelper.cs +++ b/src/TestFramework/Extension.Desktop/RuntimeTypeHelper.cs @@ -120,7 +120,7 @@ internal static MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] m { if (match == null) { - throw new ArgumentNullException("match"); + throw new ArgumentNullException(nameof(match)); } int i; @@ -420,7 +420,7 @@ internal static int FindMostSpecific( } else { - return (p1Less == true) ? 1 : 2; + return p1Less ? 1 : 2; } } diff --git a/src/TestFramework/Extension.UWP/UITestMethodAttribute.cs b/src/TestFramework/Extension.UWP/UITestMethodAttribute.cs index 6382aee862..13e4f504fe 100644 --- a/src/TestFramework/Extension.UWP/UITestMethodAttribute.cs +++ b/src/TestFramework/Extension.UWP/UITestMethodAttribute.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer /// /// Execute test code in UI thread for Windows store apps. /// - public class UITestMethodAttribute : TestMethodAttribute + public sealed class UITestMethodAttribute : TestMethodAttribute { /// /// Executes the test method on the UI Thread. @@ -35,7 +35,7 @@ public override TestResult[] Execute(ITestMethod testMethod) Windows.UI.Core.CoreDispatcherPriority.Normal, () => { - result = testMethod.Invoke(new object[] { }); + result = testMethod.Invoke(Array.Empty()); }).AsTask().GetAwaiter().GetResult(); return new TestResult[] { result }; diff --git a/src/TestFramework/MSTest.Core/Assertions/Assert.cs b/src/TestFramework/MSTest.Core/Assertions/Assert.cs index 2b0126dc72..0d049072d5 100644 --- a/src/TestFramework/MSTest.Core/Assertions/Assert.cs +++ b/src/TestFramework/MSTest.Core/Assertions/Assert.cs @@ -2182,18 +2182,17 @@ public static T ThrowsException(Func action, string message, params o public static T ThrowsException(Action action, string message, params object[] parameters) where T : Exception { - var finalMessage = string.Empty; - if (action == null) { - throw new ArgumentNullException("action"); + throw new ArgumentNullException(nameof(action)); } if (message == null) { - throw new ArgumentNullException("message"); + throw new ArgumentNullException(nameof(message)); } + string finalMessage; try { action(); @@ -2293,18 +2292,17 @@ public static async Task ThrowsExceptionAsync(Func action, string me public static async Task ThrowsExceptionAsync(Func action, string message, params object[] parameters) where T : Exception { - var finalMessage = string.Empty; - if (action == null) { - throw new ArgumentNullException("action"); + throw new ArgumentNullException(nameof(action)); } if (message == null) { - throw new ArgumentNullException("message"); + throw new ArgumentNullException(nameof(message)); } + string finalMessage; try { await action(); diff --git a/src/TestFramework/MSTest.Core/Assertions/CollectionAssert.cs b/src/TestFramework/MSTest.Core/Assertions/CollectionAssert.cs index ea84a4a6f6..cdbdef4603 100644 --- a/src/TestFramework/MSTest.Core/Assertions/CollectionAssert.cs +++ b/src/TestFramework/MSTest.Core/Assertions/CollectionAssert.cs @@ -340,7 +340,7 @@ public static void AllItemsAreUnique(ICollection collection, string message, par { if (current == null) { - if (foundNull == false) + if (!foundNull) { foundNull = true; } @@ -350,7 +350,7 @@ public static void AllItemsAreUnique(ICollection collection, string message, par var finalMessage = string.Format( CultureInfo.CurrentCulture, FrameworkMessages.AllItemsAreUniqueFailMsg, - message == null ? string.Empty : message, + message ?? string.Empty, FrameworkMessages.Common_NullInMessages); Assert.HandleFail("CollectionAssert.AllItemsAreUnique", finalMessage, parameters); @@ -363,7 +363,7 @@ public static void AllItemsAreUnique(ICollection collection, string message, par string finalMessage = string.Format( CultureInfo.CurrentCulture, FrameworkMessages.AllItemsAreUniqueFailMsg, - message == null ? string.Empty : message, + message ?? string.Empty, Assert.ReplaceNulls(current)); Assert.HandleFail("CollectionAssert.AllItemsAreUnique", finalMessage, parameters); @@ -874,8 +874,8 @@ public static void AllItemsAreInstancesOfType(ICollection collection, Type expec int i = 0; foreach (object element in collection) { - var elementTypeInfo = element != null ? element.GetType().GetTypeInfo() : null; - var expectedTypeInfo = expectedType != null ? expectedType.GetTypeInfo() : null; + var elementTypeInfo = element?.GetType().GetTypeInfo(); + var expectedTypeInfo = expectedType?.GetTypeInfo(); if (expectedTypeInfo != null && elementTypeInfo != null && !expectedTypeInfo.IsAssignableFrom(elementTypeInfo)) { var finalMessage = string.Format( diff --git a/src/TestFramework/MSTest.Core/Attributes/DataRowAttribute.cs b/src/TestFramework/MSTest.Core/Attributes/DataRowAttribute.cs index c8c641e461..009e8123b0 100644 --- a/src/TestFramework/MSTest.Core/Attributes/DataRowAttribute.cs +++ b/src/TestFramework/MSTest.Core/Attributes/DataRowAttribute.cs @@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting /// Attribute to define in-line data for a test method. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - public class DataRowAttribute : Attribute, ITestDataSource + public sealed class DataRowAttribute : Attribute, ITestDataSource { /// /// Initializes a new instance of the class. diff --git a/src/TestFramework/MSTest.Core/Attributes/DoNotParallelizeAttribute.cs b/src/TestFramework/MSTest.Core/Attributes/DoNotParallelizeAttribute.cs index 14c6d101fa..d47b562d0e 100644 --- a/src/TestFramework/MSTest.Core/Attributes/DoNotParallelizeAttribute.cs +++ b/src/TestFramework/MSTest.Core/Attributes/DoNotParallelizeAttribute.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting /// Specification to disable parallelization. /// [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] - public class DoNotParallelizeAttribute : Attribute + public sealed class DoNotParallelizeAttribute : Attribute { } } \ No newline at end of file diff --git a/src/TestFramework/MSTest.Core/Attributes/ExpectedExceptionAttribute.cs b/src/TestFramework/MSTest.Core/Attributes/ExpectedExceptionAttribute.cs index 274d322c39..a7eb801c50 100644 --- a/src/TestFramework/MSTest.Core/Attributes/ExpectedExceptionAttribute.cs +++ b/src/TestFramework/MSTest.Core/Attributes/ExpectedExceptionAttribute.cs @@ -38,14 +38,14 @@ public ExpectedExceptionAttribute(Type exceptionType, string noExceptionMessage) { if (exceptionType == null) { - throw new ArgumentNullException("exceptionType"); + throw new ArgumentNullException(nameof(exceptionType)); } if (!typeof(Exception).GetTypeInfo().IsAssignableFrom(exceptionType.GetTypeInfo())) { throw new ArgumentException( FrameworkMessages.UTF_ExpectedExceptionTypeMustDeriveFromException, - "exceptionType"); + nameof(exceptionType)); } this.ExceptionType = exceptionType; diff --git a/src/TestFramework/MSTest.Core/Attributes/ParallelizeAttribute.cs b/src/TestFramework/MSTest.Core/Attributes/ParallelizeAttribute.cs index 9564002619..9f0b67070a 100644 --- a/src/TestFramework/MSTest.Core/Attributes/ParallelizeAttribute.cs +++ b/src/TestFramework/MSTest.Core/Attributes/ParallelizeAttribute.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting /// Specification for parallelization level for a test run. /// [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] - public class ParallelizeAttribute : Attribute + public sealed class ParallelizeAttribute : Attribute { private const int DefaultParallelWorkers = 0; diff --git a/src/TestFramework/MSTest.Core/Attributes/TestCategoryAttribute.cs b/src/TestFramework/MSTest.Core/Attributes/TestCategoryAttribute.cs index 6a801f7f1b..6b17e8a2c4 100644 --- a/src/TestFramework/MSTest.Core/Attributes/TestCategoryAttribute.cs +++ b/src/TestFramework/MSTest.Core/Attributes/TestCategoryAttribute.cs @@ -24,8 +24,10 @@ public sealed class TestCategoryAttribute : TestCategoryBaseAttribute /// public TestCategoryAttribute(string testCategory) { - List categories = new List(1); - categories.Add(testCategory); + List categories = new List(1) + { + testCategory + }; this.testCategories = categories; } diff --git a/src/TestFramework/MSTest.Core/Attributes/VSTestAttributes.cs b/src/TestFramework/MSTest.Core/Attributes/VSTestAttributes.cs index 32aac7bf0b..f19188e44f 100644 --- a/src/TestFramework/MSTest.Core/Attributes/VSTestAttributes.cs +++ b/src/TestFramework/MSTest.Core/Attributes/VSTestAttributes.cs @@ -107,7 +107,7 @@ public virtual TestResult[] Execute(ITestMethod testMethod) /// Attribute for data driven test where data can be specified in-line. /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - public class DataTestMethodAttribute : TestMethodAttribute + public sealed class DataTestMethodAttribute : TestMethodAttribute { } diff --git a/src/TestFramework/MSTest.Core/Logger.cs b/src/TestFramework/MSTest.Core/Logger.cs index c0c3739931..81cc0d1569 100644 --- a/src/TestFramework/MSTest.Core/Logger.cs +++ b/src/TestFramework/MSTest.Core/Logger.cs @@ -37,7 +37,7 @@ public static void LogMessage(string format, params object[] args) { if (format == null) { - throw new ArgumentNullException("format"); + throw new ArgumentNullException(nameof(format)); } string message = string.Format(CultureInfo.InvariantCulture, format, args); diff --git a/src/TestFramework/MSTest.Core/UnitTestOutcome.cs b/src/TestFramework/MSTest.Core/UnitTestOutcome.cs index f90353d4f5..dc94d92e0e 100644 --- a/src/TestFramework/MSTest.Core/UnitTestOutcome.cs +++ b/src/TestFramework/MSTest.Core/UnitTestOutcome.cs @@ -6,7 +6,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting /// /// unit test outcomes /// - public enum UnitTestOutcome : int + public enum UnitTestOutcome { /// /// Test was executed, but there were issues. diff --git a/test/E2ETests/TestAssets/FxExtensibilityTestProject/CustomTestExTests.cs b/test/E2ETests/TestAssets/FxExtensibilityTestProject/CustomTestExTests.cs index c42be4a431..0e5b968f3a 100644 --- a/test/E2ETests/TestAssets/FxExtensibilityTestProject/CustomTestExTests.cs +++ b/test/E2ETests/TestAssets/FxExtensibilityTestProject/CustomTestExTests.cs @@ -32,7 +32,7 @@ public void CustomTestClass1() } } - public class IterativeTestMethodAttribute : TestMethodAttribute + public sealed class IterativeTestMethodAttribute : TestMethodAttribute { private readonly int stabilityThreshold; @@ -58,7 +58,7 @@ public override TestResult[] Execute(ITestMethod testMethod) } } - public class IterativeTestClassAttribute : TestClassAttribute + public sealed class IterativeTestClassAttribute : TestClassAttribute { private readonly int stabilityThreshold; diff --git a/test/E2ETests/TestAssets/FxExtensibilityTestProject/Properties/AssemblyInfo.cs b/test/E2ETests/TestAssets/FxExtensibilityTestProject/Properties/AssemblyInfo.cs index 893dae4a13..da2d4317de 100644 --- a/test/E2ETests/TestAssets/FxExtensibilityTestProject/Properties/AssemblyInfo.cs +++ b/test/E2ETests/TestAssets/FxExtensibilityTestProject/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ 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/E2ETests/TestAssets/FxExtensibilityTestProject/TestDataSourceExTests.cs b/test/E2ETests/TestAssets/FxExtensibilityTestProject/TestDataSourceExTests.cs index 022a471851..0f151f56dd 100644 --- a/test/E2ETests/TestAssets/FxExtensibilityTestProject/TestDataSourceExTests.cs +++ b/test/E2ETests/TestAssets/FxExtensibilityTestProject/TestDataSourceExTests.cs @@ -21,7 +21,7 @@ public void CustomTestDataSourceTestMethod1(int a, int b, int c) } [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - public class CustomTestDataSourceAttribute : Attribute, ITestDataSource + public sealed class CustomTestDataSourceAttribute : Attribute, ITestDataSource { public IEnumerable GetData(MethodInfo methodInfo) { diff --git a/test/E2ETests/TestAssets/ParallelTestClass/Properties/AssemblyInfo.cs b/test/E2ETests/TestAssets/ParallelTestClass/Properties/AssemblyInfo.cs index 743ebee94b..4f54c36ef8 100644 --- a/test/E2ETests/TestAssets/ParallelTestClass/Properties/AssemblyInfo.cs +++ b/test/E2ETests/TestAssets/ParallelTestClass/Properties/AssemblyInfo.cs @@ -1,7 +1,5 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Microsoft.VisualStudio.TestTools.UnitTesting; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information diff --git a/test/E2ETests/TestAssets/ParallelTestMethods/Properties/AssemblyInfo.cs b/test/E2ETests/TestAssets/ParallelTestMethods/Properties/AssemblyInfo.cs index e9bb21ce0c..f805e4b174 100644 --- a/test/E2ETests/TestAssets/ParallelTestMethods/Properties/AssemblyInfo.cs +++ b/test/E2ETests/TestAssets/ParallelTestMethods/Properties/AssemblyInfo.cs @@ -1,7 +1,5 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Microsoft.VisualStudio.TestTools.UnitTesting; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information diff --git a/test/E2ETests/TestAssets/TimeoutTestProject/SelfTerminatingTestClass.cs b/test/E2ETests/TestAssets/TimeoutTestProject/SelfTerminatingTestClass.cs index 9945962493..24c97b8e2c 100644 --- a/test/E2ETests/TestAssets/TimeoutTestProject/SelfTerminatingTestClass.cs +++ b/test/E2ETests/TestAssets/TimeoutTestProject/SelfTerminatingTestClass.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TimeoutTestProject { diff --git a/test/E2ETests/TestAssets/TimeoutTestProject/TerimnateLongRunningTasksUsingTokenTestClass.cs b/test/E2ETests/TestAssets/TimeoutTestProject/TerimnateLongRunningTasksUsingTokenTestClass.cs index 808f7af935..3012915e30 100644 --- a/test/E2ETests/TestAssets/TimeoutTestProject/TerimnateLongRunningTasksUsingTokenTestClass.cs +++ b/test/E2ETests/TestAssets/TimeoutTestProject/TerimnateLongRunningTasksUsingTokenTestClass.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/test/E2ETests/TestAssets/TimeoutTestProjectNetCore/SelfTerminatingTestClass.cs b/test/E2ETests/TestAssets/TimeoutTestProjectNetCore/SelfTerminatingTestClass.cs index 9945962493..24c97b8e2c 100644 --- a/test/E2ETests/TestAssets/TimeoutTestProjectNetCore/SelfTerminatingTestClass.cs +++ b/test/E2ETests/TestAssets/TimeoutTestProjectNetCore/SelfTerminatingTestClass.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TimeoutTestProject { diff --git a/test/E2ETests/TestAssets/TimeoutTestProjectNetCore/TerimnateLongRunningTasksUsingTokenTestClass.cs b/test/E2ETests/TestAssets/TimeoutTestProjectNetCore/TerimnateLongRunningTasksUsingTokenTestClass.cs index 2147c35b66..34cae0b840 100644 --- a/test/E2ETests/TestAssets/TimeoutTestProjectNetCore/TerimnateLongRunningTasksUsingTokenTestClass.cs +++ b/test/E2ETests/TestAssets/TimeoutTestProjectNetCore/TerimnateLongRunningTasksUsingTokenTestClass.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/test/UnitTests/MSTest.Core.Unit.Tests/Attributes/DataRowAttributeTests.cs b/test/UnitTests/MSTest.Core.Unit.Tests/Attributes/DataRowAttributeTests.cs index 93b8f5076f..f0e38e4ff3 100644 --- a/test/UnitTests/MSTest.Core.Unit.Tests/Attributes/DataRowAttributeTests.cs +++ b/test/UnitTests/MSTest.Core.Unit.Tests/Attributes/DataRowAttributeTests.cs @@ -93,8 +93,10 @@ public void GetDisplayNameShouldReturnAppropriateName() [TestMethod] public void GetDisplayNameShouldReturnSpecifiedDisplayName() { - var dataRowAttribute = new DataRowAttribute(null); - dataRowAttribute.DisplayName = "DataRowTestWithDisplayName"; + var dataRowAttribute = new DataRowAttribute(null) + { + DisplayName = "DataRowTestWithDisplayName" + }; this.dummyTestClass = new DummyTestClass(); this.testMethodInfo = this.dummyTestClass.GetType().GetTypeInfo().GetDeclaredMethod("DataRowTestMethod"); diff --git a/test/UnitTests/MSTest.Core.Unit.Tests/Attributes/ExpectedExceptionBaseAttributeTests.cs b/test/UnitTests/MSTest.Core.Unit.Tests/Attributes/ExpectedExceptionBaseAttributeTests.cs index e74692a706..7002380490 100644 --- a/test/UnitTests/MSTest.Core.Unit.Tests/Attributes/ExpectedExceptionBaseAttributeTests.cs +++ b/test/UnitTests/MSTest.Core.Unit.Tests/Attributes/ExpectedExceptionBaseAttributeTests.cs @@ -76,7 +76,7 @@ public void VerifyEmptytMessageIsGettingSetInVariablenoExceptionMessage() /// /// Dummy class derived from Exception /// - public class TestableExpectedExceptionBaseAttributeClass : TestFrameworkV2.ExpectedExceptionBaseAttribute + public sealed class TestableExpectedExceptionBaseAttributeClass : TestFrameworkV2.ExpectedExceptionBaseAttribute { public TestableExpectedExceptionBaseAttributeClass() : base() diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Discovery/AssemblyEnumeratorTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Discovery/AssemblyEnumeratorTests.cs index 17a9edda4f..a5c847a285 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Discovery/AssemblyEnumeratorTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Discovery/AssemblyEnumeratorTests.cs @@ -243,7 +243,7 @@ public void EnumerateAssemblyShouldReturnEmptyListWhenNoDeclaredTypes() this.testablePlatformServiceProvider.MockFileOperations.Setup(fo => fo.LoadAssembly("DummyAssembly", false)) .Returns(mockAssembly.Object); - Assert.AreEqual(0, this.assemblyEnumerator.EnumerateAssembly("DummyAssembly", out this.warnings).Count()); + Assert.AreEqual(0, this.assemblyEnumerator.EnumerateAssembly("DummyAssembly", out this.warnings).Count); } [TestMethodV1] @@ -260,7 +260,7 @@ public void EnumerateAssemblyShouldReturnEmptyListWhenNoTestElementsInAType() testableAssemblyEnumerator.MockTypeEnumerator.Setup(te => te.Enumerate(out this.warnings)) .Returns((ICollection)null); - Assert.AreEqual(0, this.assemblyEnumerator.EnumerateAssembly("DummyAssembly", out this.warnings).Count()); + Assert.AreEqual(0, this.assemblyEnumerator.EnumerateAssembly("DummyAssembly", out this.warnings).Count); } [TestMethodV1] @@ -370,9 +370,10 @@ public void EnumerateAssemblyShouldLogWarningsIfPresent() { var mockAssembly = new Mock(); var testableAssemblyEnumerator = new TestableAssemblyEnumerator(); - ICollection warningsFromTypeEnumerator = new Collection(); - - warningsFromTypeEnumerator.Add("DummyWarning"); + ICollection warningsFromTypeEnumerator = new Collection + { + "DummyWarning" + }; // Setup mocks mockAssembly.Setup(a => a.DefinedTypes) diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestClassInfoTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestClassInfoTests.cs index a5c7cadf8a..8f30ae0a95 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestClassInfoTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestClassInfoTests.cs @@ -663,7 +663,7 @@ public static void ClassCleanupMethod() } } - private class DummyTestClassAttribute : UTF.TestClassAttribute + private sealed class DummyTestClassAttribute : UTF.TestClassAttribute { } } diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs index 996b91d1d5..d4d03860a9 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs @@ -1129,7 +1129,7 @@ public void TestMethod4() } } - private class DummyTestClassAttribute : UTF.TestClassAttribute + private sealed class DummyTestClassAttribute : UTF.TestClassAttribute { } diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestMethodFilterTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestMethodFilterTests.cs index 3759a38a9f..314cab9228 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestMethodFilterTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestMethodFilterTests.cs @@ -283,7 +283,7 @@ public bool MatchTestCase(TestCase testCase, Func propertyValueP } } - private class DummyTestClassAttribute : UTF.TestClassAttribute + private sealed class DummyTestClassAttribute : UTF.TestClassAttribute { } } diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestMethodInfoTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestMethodInfoTests.cs index 1f915aba00..bb2d0417dd 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestMethodInfoTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestMethodInfoTests.cs @@ -861,8 +861,10 @@ public void TestMethodInfoInvokeShouldCallDiposeForDisposableTestClassIfTestClea DummyTestClassWithDisposable.DisposeMethodBody = () => disposeCalled = true; DummyTestClassWithDisposable.DummyTestCleanupMethodBody = classInstance => { throw new NotImplementedException(); }; var ctorInfo = typeof(DummyTestClassWithDisposable).GetConstructors().Single(); - var testClass = new TestClassInfo(typeof(DummyTestClassWithDisposable), ctorInfo, null, this.classAttribute, this.testAssemblyInfo); - testClass.TestCleanupMethod = typeof(DummyTestClassWithDisposable).GetMethod("DummyTestCleanupMethod"); + var testClass = new TestClassInfo(typeof(DummyTestClassWithDisposable), ctorInfo, null, this.classAttribute, this.testAssemblyInfo) + { + TestCleanupMethod = typeof(DummyTestClassWithDisposable).GetMethod("DummyTestCleanupMethod") + }; var method = new TestMethodInfo(typeof(DummyTestClassWithDisposable).GetMethod("DummyTestMethod"), testClass, this.testMethodOptions); method.Invoke(null); @@ -1071,8 +1073,10 @@ public void HandleMethodExceptionShouldInvokeVerifyOfDerivedCustomExpectedExcept [TestMethodV1] public void VerifyShouldNotThrowIfThrownExceptionCanBeAssignedToExpectedException() { - UTF.ExpectedExceptionAttribute expectedException = new UTF.ExpectedExceptionAttribute(typeof(Exception)); - expectedException.AllowDerivedTypes = true; + UTF.ExpectedExceptionAttribute expectedException = new UTF.ExpectedExceptionAttribute(typeof(Exception)) + { + AllowDerivedTypes = true + }; this.testMethodOptions.Timeout = 0; this.testMethodOptions.ExpectedException = expectedException; var method = new TestMethodInfo( @@ -1088,8 +1092,10 @@ public void VerifyShouldNotThrowIfThrownExceptionCanBeAssignedToExpectedExceptio [TestMethodV1] public void VerifyShouldThrowExceptionIfThrownExceptionCannotBeAssignedToExpectedException() { - UTF.ExpectedExceptionAttribute expectedException = new UTF.ExpectedExceptionAttribute(typeof(DivideByZeroException), "Custom Exception"); - expectedException.AllowDerivedTypes = true; + UTF.ExpectedExceptionAttribute expectedException = new UTF.ExpectedExceptionAttribute(typeof(DivideByZeroException), "Custom Exception") + { + AllowDerivedTypes = true + }; this.testMethodOptions.Timeout = 0; this.testMethodOptions.ExpectedException = expectedException; var method = new TestMethodInfo( @@ -1108,8 +1114,10 @@ public void VerifyShouldThrowExceptionIfThrownExceptionCannotBeAssignedToExpecte [TestMethodV1] public void VerifyShouldRethrowExceptionIfThrownExceptionIsAssertFailedException() { - UTF.ExpectedExceptionAttribute expectedException = new UTF.ExpectedExceptionAttribute(typeof(DivideByZeroException)); - expectedException.AllowDerivedTypes = true; + UTF.ExpectedExceptionAttribute expectedException = new UTF.ExpectedExceptionAttribute(typeof(DivideByZeroException)) + { + AllowDerivedTypes = true + }; this.testMethodOptions.Timeout = 0; this.testMethodOptions.ExpectedException = expectedException; var method = new TestMethodInfo( @@ -1127,8 +1135,10 @@ public void VerifyShouldRethrowExceptionIfThrownExceptionIsAssertFailedException [TestMethodV1] public void VerifyShouldRethrowExceptionIfThrownExceptionIsAssertInconclusiveException() { - UTF.ExpectedExceptionAttribute expectedException = new UTF.ExpectedExceptionAttribute(typeof(DivideByZeroException)); - expectedException.AllowDerivedTypes = true; + UTF.ExpectedExceptionAttribute expectedException = new UTF.ExpectedExceptionAttribute(typeof(DivideByZeroException)) + { + AllowDerivedTypes = true + }; this.testMethodOptions.Timeout = 0; this.testMethodOptions.ExpectedException = expectedException; var method = new TestMethodInfo( @@ -1597,7 +1607,7 @@ protected override void Verify(Exception exception) /// /// Custom Expected exception attribute which overrides the Verify method. /// - public class DerivedCustomExpectedExceptionAttribute : CustomExpectedExceptionAttribute + public sealed class DerivedCustomExpectedExceptionAttribute : CustomExpectedExceptionAttribute { public DerivedCustomExpectedExceptionAttribute(Type expectionType, string noExceptionMessage) : base(expectionType, noExceptionMessage) diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TypeCacheTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TypeCacheTests.cs index ea7be9e8ca..51c2d971e4 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TypeCacheTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TypeCacheTests.cs @@ -1698,11 +1698,11 @@ public static void TestMethod() } } - private class DerivedTestMethodAttribute : UTF.TestMethodAttribute + private sealed class DerivedTestMethodAttribute : UTF.TestMethodAttribute { } - private class DummyTestClassAttribute : UTF.TestClassAttribute + private sealed class DummyTestClassAttribute : UTF.TestClassAttribute { } diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/UnitTestRunnerTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/UnitTestRunnerTests.cs index e7795818a5..7ab3ae04c9 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/UnitTestRunnerTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/UnitTestRunnerTests.cs @@ -224,8 +224,8 @@ public void RunSingleTestShouldCallAssemblyInitializeAndClassInitializeMethodsIn It.IsAny())).Returns(true); var validator = 1; - DummyTestClassWithInitializeMethods.AssemblyInitializeMethodBody = () => { validator = validator << 2; }; - DummyTestClassWithInitializeMethods.ClassInitializeMethodBody = () => { validator = validator >> 2; }; + DummyTestClassWithInitializeMethods.AssemblyInitializeMethodBody = () => { validator <<= 2; }; + DummyTestClassWithInitializeMethods.ClassInitializeMethodBody = () => { validator >>= 2; }; this.unitTestRunner.RunSingleTest(testMethod, this.testRunParameters); @@ -294,7 +294,7 @@ public void RunCleanupShouldReturnCleanupResultsWithDebugTraceLogsSetIfDebugTrac this.unitTestRunner.RunSingleTest(testMethod, this.testRunParameters); var cleanupresult = this.unitTestRunner.RunCleanup(); - Assert.AreEqual(cleanupresult.DebugTrace, "DummyTrace"); + Assert.AreEqual("DummyTrace", cleanupresult.DebugTrace); } [TestMethodV1] @@ -412,7 +412,7 @@ public void TestMethod() } } - private class DummyTestClassAttribute : UTF.TestClassAttribute + private sealed class DummyTestClassAttribute : UTF.TestClassAttribute { } diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Extensions/ExceptionExtensionsTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Extensions/ExceptionExtensionsTests.cs index 5b4209afa7..20b06fe76b 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Extensions/ExceptionExtensionsTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Extensions/ExceptionExtensionsTests.cs @@ -176,9 +176,9 @@ public DummyException(Func message) public void IsUnitTestAssertExceptionReturnsTrueIfExceptionIsAssertException() { var exception = new UTF.AssertInconclusiveException(); - UTF.UnitTestOutcome outcome = UTF.UnitTestOutcome.Unknown; - string exceptionMessage = null; - StackTraceInformation stackTraceInfo = null; + UTF.UnitTestOutcome outcome; + string exceptionMessage; + StackTraceInformation stackTraceInfo; Assert.IsTrue(exception.TryGetUnitTestAssertException(out outcome, out exceptionMessage, out stackTraceInfo)); } @@ -187,9 +187,9 @@ public void IsUnitTestAssertExceptionReturnsTrueIfExceptionIsAssertException() public void IsUnitTestAssertExceptionReturnsFalseIfExceptionIsNotAssertException() { var exception = new NotImplementedException(); - UTF.UnitTestOutcome outcome = UTF.UnitTestOutcome.Unknown; - string exceptionMessage = null; - StackTraceInformation stackTraceInfo = null; + UTF.UnitTestOutcome outcome; + string exceptionMessage; + StackTraceInformation stackTraceInfo; Assert.IsFalse(exception.TryGetUnitTestAssertException(out outcome, out exceptionMessage, out stackTraceInfo)); } @@ -198,9 +198,9 @@ public void IsUnitTestAssertExceptionReturnsFalseIfExceptionIsNotAssertException public void IsUnitTestAssertExceptionSetsOutcomeAsInconclusiveIfAssertInconclusiveException() { var exception = new UTF.AssertInconclusiveException("Dummy Message", new NotImplementedException("notImplementedException")); - UTF.UnitTestOutcome outcome = UTF.UnitTestOutcome.Unknown; - string exceptionMessage = null; - StackTraceInformation stackTraceInfo = null; + UTF.UnitTestOutcome outcome; + string exceptionMessage; + StackTraceInformation stackTraceInfo; exception.TryGetUnitTestAssertException(out outcome, out exceptionMessage, out stackTraceInfo); @@ -212,9 +212,9 @@ public void IsUnitTestAssertExceptionSetsOutcomeAsInconclusiveIfAssertInconclusi public void IsUnitTestAssertExceptionSetsOutcomeAsFailedIfAssertFailedException() { var exception = new UTF.AssertFailedException("Dummy Message", new NotImplementedException("notImplementedException")); - UTF.UnitTestOutcome outcome = UTF.UnitTestOutcome.Unknown; - string exceptionMessage = null; - StackTraceInformation stackTraceInfo = null; + UTF.UnitTestOutcome outcome; + string exceptionMessage; + StackTraceInformation stackTraceInfo; exception.TryGetUnitTestAssertException(out outcome, out exceptionMessage, out stackTraceInfo); diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Extensions/TestCaseExtensionsTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Extensions/TestCaseExtensionsTests.cs index 01a864ad02..1f9e440e74 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Extensions/TestCaseExtensionsTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Extensions/TestCaseExtensionsTests.cs @@ -20,8 +20,11 @@ public class TestCaseExtensionsTests [TestMethod] public void ToUnitTestElementShouldReturnUnitTestElementWithFieldsSet() { - TestCase testCase = new TestCase("DummyClassName.DummyMethod", new Uri("DummyUri", UriKind.Relative), Assembly.GetCallingAssembly().FullName); - testCase.DisplayName = "DummyDisplayName"; + TestCase testCase = new TestCase("DummyClass.DummyMethod", new Uri("DummyUri", UriKind.Relative), Assembly.GetCallingAssembly().FullName) + { + DisplayName = "DummyDisplayName" + }; + var testCategories = new[] { "DummyCategory" }; testCase.SetPropertyValue(Constants.AsyncTestProperty, true); diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Helpers/ReflectHelperTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Helpers/ReflectHelperTests.cs index 49bb940e5f..d4798c0b45 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Helpers/ReflectHelperTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Helpers/ReflectHelperTests.cs @@ -317,7 +317,7 @@ public void HasAttributeDerivedFromShouldReturnTrueQueryingProvidedAttributesExi #region Dummy Implmentations - public class TestableExtendedTestMethod : UTF.TestMethodAttribute + public sealed class TestableExtendedTestMethod : UTF.TestMethodAttribute { } diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTestDiscovererTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTestDiscovererTests.cs index 395e8c1f84..c910ee5f03 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTestDiscovererTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/MSTestDiscovererTests.cs @@ -71,7 +71,7 @@ public void MSTestDiscovererHasXapAsFileExtension() { IEnumerable attributes = typeof(MSTestDiscoverer).GetTypeInfo().GetCustomAttributes(typeof(FileExtensionAttribute)).Cast(); Assert.IsNotNull(attributes); - Assert.AreEqual(1, attributes.Where(attribute => attribute.FileExtension == ".xap").Count()); + Assert.AreEqual(1, attributes.Count(attribute => attribute.FileExtension == ".xap")); } [TestMethod] @@ -79,7 +79,7 @@ public void MSTestDiscovererHasAppxAsFileExtension() { IEnumerable attributes = typeof(MSTestDiscoverer).GetTypeInfo().GetCustomAttributes(typeof(FileExtensionAttribute)).Cast(); Assert.IsNotNull(attributes); - Assert.AreEqual(1, attributes.Where(attribute => attribute.FileExtension == ".appx").Count()); + Assert.AreEqual(1, attributes.Count(attribute => attribute.FileExtension == ".appx")); } [TestMethod] @@ -87,7 +87,7 @@ public void MSTestDiscovererHasDllAsFileExtension() { IEnumerable attributes = typeof(MSTestDiscoverer).GetTypeInfo().GetCustomAttributes(typeof(FileExtensionAttribute)).Cast(); Assert.IsNotNull(attributes); - Assert.AreEqual(1, attributes.Where(attribute => attribute.FileExtension == ".dll").Count()); + Assert.AreEqual(1, attributes.Count(attribute => attribute.FileExtension == ".dll")); } [TestMethod] @@ -95,7 +95,7 @@ public void MSTestDiscovererHasExeAsFileExtension() { IEnumerable attributes = typeof(MSTestDiscoverer).GetTypeInfo().GetCustomAttributes(typeof(FileExtensionAttribute)).Cast(); Assert.IsNotNull(attributes); - Assert.AreEqual(1, attributes.Where(attribute => attribute.FileExtension == ".exe").Count()); + Assert.AreEqual(1, attributes.Count(attribute => attribute.FileExtension == ".exe")); } [TestMethod] diff --git a/test/UnitTests/PlatformServices.Desktop.Unit.Tests/AssemblyResolverTests.cs b/test/UnitTests/PlatformServices.Desktop.Unit.Tests/AssemblyResolverTests.cs index e09bd17873..622328ea2c 100644 --- a/test/UnitTests/PlatformServices.Desktop.Unit.Tests/AssemblyResolverTests.cs +++ b/test/UnitTests/PlatformServices.Desktop.Unit.Tests/AssemblyResolverTests.cs @@ -28,31 +28,34 @@ public void AddSubDirectoriesShouldReturnSubDirectoriesInDfsOrder() string path = @"C:\unitTesting"; List searchDirectories = new List(); - List resultDirectories = new List(); - resultDirectories.Add(@"C:\unitTesting\a"); - resultDirectories.Add(@"C:\unitTesting\a\c"); - resultDirectories.Add(@"C:\unitTesting\a\c\d"); - resultDirectories.Add(@"C:\unitTesting\b"); - - TestableAssemblyResolver assemblyResolver = new TestableAssemblyResolver(new List { @"c:\dummy" }); + List resultDirectories = new List + { + @"C:\unitTesting\a", + @"C:\unitTesting\a\c", + @"C:\unitTesting\a\c\d", + @"C:\unitTesting\b" + }; - assemblyResolver.DoesDirectoryExistSetter = (str) => true; - assemblyResolver.GetDirectoriesSetter = (str) => + TestableAssemblyResolver assemblyResolver = new TestableAssemblyResolver(new List { @"c:\dummy" }) { - if (string.Compare(path, str, StringComparison.OrdinalIgnoreCase) == 0) - { - return new string[] { @"C:\unitTesting\a", @"C:\unitTesting\b" }; - } - else if (string.Compare(@"C:\unitTesting\a", str, StringComparison.OrdinalIgnoreCase) == 0) - { - return new string[] { @"C:\unitTesting\a\c" }; - } - else if (string.Compare(@"C:\unitTesting\a\c", str, StringComparison.OrdinalIgnoreCase) == 0) + DoesDirectoryExistSetter = (str) => true, + GetDirectoriesSetter = (str) => { - return new string[] { @"C:\unitTesting\a\c\d" }; - } + if (string.Compare(path, str, StringComparison.OrdinalIgnoreCase) == 0) + { + return new string[] { @"C:\unitTesting\a", @"C:\unitTesting\b" }; + } + else if (string.Compare(@"C:\unitTesting\a", str, StringComparison.OrdinalIgnoreCase) == 0) + { + return new string[] { @"C:\unitTesting\a\c" }; + } + else if (string.Compare(@"C:\unitTesting\a\c", str, StringComparison.OrdinalIgnoreCase) == 0) + { + return new string[] { @"C:\unitTesting\a\c\d" }; + } - return new List().ToArray(); + return new List().ToArray(); + } }; // Act. @@ -69,12 +72,16 @@ public void OnResolveShouldAddSearchDirectoryListOnANeedToBasis() { int count = 0; - List recursiveDirectoryPath = new List(); - recursiveDirectoryPath.Add(new RecursiveDirectoryPath(@"C:\unitTesting", true)); - recursiveDirectoryPath.Add(new RecursiveDirectoryPath(@"C:\FunctionalTesting", false)); + List recursiveDirectoryPath = new List + { + new RecursiveDirectoryPath(@"C:\unitTesting", true), + new RecursiveDirectoryPath(@"C:\FunctionalTesting", false) + }; - List dummyDirectories = new List(); - dummyDirectories.Add(@"c:\dummy"); + List dummyDirectories = new List + { + @"c:\dummy" + }; TestableAssemblyResolver assemblyResolver = new TestableAssemblyResolver(dummyDirectories); // Adding search directory with recursive property true/false diff --git a/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Deployment/AssemblyLoadWorkerTests.cs b/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Deployment/AssemblyLoadWorkerTests.cs index 76c0546e5f..00a42b330d 100644 --- a/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Deployment/AssemblyLoadWorkerTests.cs +++ b/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Deployment/AssemblyLoadWorkerTests.cs @@ -28,11 +28,13 @@ public void GetFullPathToDependentAssembliesShouldReturnV1FrameworkAssembly() { // Arrange. var v1AssemblyName = new AssemblyName("Microsoft.VisualStudio.QualityTools.UnitTestFramework"); - var testableAssembly = new TestableAssembly(); - testableAssembly.GetReferencedAssembliesSetter = () => - { - return new AssemblyName[] { v1AssemblyName }; - }; + var testableAssembly = new TestableAssembly + { + GetReferencedAssembliesSetter = () => + { + return new AssemblyName[] { v1AssemblyName }; + } + }; var mockAssemblyUtility = new Mock(); mockAssemblyUtility.Setup(au => au.ReflectionOnlyLoadFrom(It.IsAny())).Returns(testableAssembly); @@ -57,16 +59,20 @@ public void GetFullPathToDependentAssembliesShouldReturnV1FrameworkReferencedInA var v1AssemblyName = new AssemblyName("Microsoft.VisualStudio.QualityTools.UnitTestFramework"); var dependentAssemblyName = new AssemblyName("Common.TestFramework"); - var dependentAssembly = new TestableAssembly(dependentAssemblyName.Name); - dependentAssembly.GetReferencedAssembliesSetter = () => + var dependentAssembly = new TestableAssembly(dependentAssemblyName.Name) { - return new AssemblyName[] { v1AssemblyName }; + GetReferencedAssembliesSetter = () => + { + return new AssemblyName[] { v1AssemblyName }; + } }; - var testableAssembly = new TestableAssembly(); - testableAssembly.GetReferencedAssembliesSetter = () => + var testableAssembly = new TestableAssembly { - return new AssemblyName[] { dependentAssemblyName }; + GetReferencedAssembliesSetter = () => + { + return new AssemblyName[] { dependentAssemblyName }; + } }; var mockAssemblyUtility = new Mock(); diff --git a/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Services/DesktopTestDataSourceTests.cs b/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Services/DesktopTestDataSourceTests.cs index e69e75cbf2..c412c718bf 100644 --- a/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Services/DesktopTestDataSourceTests.cs +++ b/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Services/DesktopTestDataSourceTests.cs @@ -89,15 +89,15 @@ public DesktopTestFrameworkV2.TestContext TestContext [TestFrameworkV2.TestMethod] public void PassingTest() { - Assert.AreEqual(this.testContextInstance.DataRow["adapter"].ToString(), "v1"); - Assert.AreEqual(this.testContextInstance.DataRow["targetPlatform"].ToString(), "x86"); + Assert.AreEqual("v1", this.testContextInstance.DataRow["adapter"].ToString()); + Assert.AreEqual("x86", this.testContextInstance.DataRow["targetPlatform"].ToString()); this.TestContext.AddResultFile("C:\\temp.txt"); } [TestFrameworkV2.TestMethod] public void FailingTest() { - Assert.AreEqual(this.testContextInstance.DataRow["configuration"].ToString(), "Release"); + Assert.AreEqual("Release", this.testContextInstance.DataRow["configuration"].ToString()); } } diff --git a/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Utilities/DesktopReflectionUtilityTests.cs b/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Utilities/DesktopReflectionUtilityTests.cs index 3986db4ebf..9ecddb5763 100644 --- a/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Utilities/DesktopReflectionUtilityTests.cs +++ b/test/UnitTests/PlatformServices.Desktop.Unit.Tests/Utilities/DesktopReflectionUtilityTests.cs @@ -103,7 +103,7 @@ public DummyAAttribute(string foo) } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)] - public class DummySingleAAttribute : Attribute + public sealed class DummySingleAAttribute : Attribute { public DummySingleAAttribute(string foo) { diff --git a/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Services/ns10MSTestAdapterSettingsTests.cs b/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Services/ns10MSTestAdapterSettingsTests.cs index f897f83f98..2f652c318d 100644 --- a/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Services/ns10MSTestAdapterSettingsTests.cs +++ b/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Services/ns10MSTestAdapterSettingsTests.cs @@ -47,8 +47,10 @@ public void ResolveEnvironmentVariableShouldResolvePathWhenPassedAbsolutePath() string baseDirectory = null; string expectedResult = @"C:\MsTest\Adapter"; - var adapterSettings = new TestableMSTestAdapterSettings(); - adapterSettings.DoesDirectoryExistSetter = (str) => { return true; }; + var adapterSettings = new TestableMSTestAdapterSettings + { + DoesDirectoryExistSetter = (str) => { return true; } + }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); @@ -63,9 +65,11 @@ public void ResolveEnvironmentVariableShouldResolvePathWithAnEnvironmentVariable string baseDirectory = null; string expectedResult = @"C:\foo\unitTesting\MsTest\Adapter"; - var adapterSettings = new TestableMSTestAdapterSettings(); - adapterSettings.ExpandEnvironmentVariablesSetter = (str) => { return str.Replace("%temp%", "C:\\foo"); }; - adapterSettings.DoesDirectoryExistSetter = (str) => { return true; }; + var adapterSettings = new TestableMSTestAdapterSettings + { + ExpandEnvironmentVariablesSetter = (str) => { return str.Replace("%temp%", "C:\\foo"); }, + DoesDirectoryExistSetter = (str) => { return true; } + }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); @@ -80,8 +84,10 @@ public void ResolveEnvironmentVariableShouldResolvePathWhenPassedRelativePathWit string baseDirectory = @"C:\unitTesting"; string expectedResult = @"C:\unitTesting\MsTest\Adapter"; - var adapterSettings = new TestableMSTestAdapterSettings(); - adapterSettings.DoesDirectoryExistSetter = (str) => { return true; }; + var adapterSettings = new TestableMSTestAdapterSettings + { + DoesDirectoryExistSetter = (str) => { return true; } + }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); @@ -96,8 +102,10 @@ public void ResolveEnvironmentVariableShouldResolvePathWhenPassedRelativePathWit string baseDirectory = @"C:\unitTesting"; string expectedResult = @"C:\unitTesting\MsTest\Adapter"; - var adapterSettings = new TestableMSTestAdapterSettings(); - adapterSettings.DoesDirectoryExistSetter = (str) => { return true; }; + var adapterSettings = new TestableMSTestAdapterSettings + { + DoesDirectoryExistSetter = (str) => { return true; } + }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); @@ -118,8 +126,10 @@ public void ResolveEnvironmentVariableShouldResolvePathWhenPassedRelativePath() string currentDrive = currentDirectory.Split('\\').First() + "\\"; string expectedResult = Path.Combine(currentDrive, @"MsTest\Adapter"); - var adapterSettings = new TestableMSTestAdapterSettings(); - adapterSettings.DoesDirectoryExistSetter = (str) => { return true; }; + var adapterSettings = new TestableMSTestAdapterSettings + { + DoesDirectoryExistSetter = (str) => { return true; } + }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); @@ -135,8 +145,10 @@ public void ResolveEnvironmentVariableShouldResolvePathWhenPassedNetworkPath() string expectedResult = path; - var adapterSettings = new TestableMSTestAdapterSettings(); - adapterSettings.DoesDirectoryExistSetter = (str) => { return true; }; + var adapterSettings = new TestableMSTestAdapterSettings + { + DoesDirectoryExistSetter = (str) => { return true; } + }; string result = adapterSettings.ResolveEnvironmentVariableAndReturnFullPathIfExist(path, baseDirectory); @@ -164,13 +176,17 @@ public void GetDirectoryListWithRecursivePropertyShouldReadRunSettingCorrectly() { string baseDirectory = @"C:\unitTesting"; - List expectedResult = new List(); - expectedResult.Add(new RecursiveDirectoryPath(@"C:\MsTest\Adapter", true)); - expectedResult.Add(new RecursiveDirectoryPath(@"C:\foo\unitTesting\MsTest\Adapter", false)); + List expectedResult = new List + { + new RecursiveDirectoryPath(@"C:\MsTest\Adapter", true), + new RecursiveDirectoryPath(@"C:\foo\unitTesting\MsTest\Adapter", false) + }; - var adapterSettings = new TestableMSTestAdapterSettings(expectedResult); - adapterSettings.ExpandEnvironmentVariablesSetter = (str) => { return str.Replace("%temp%", "C:\\foo"); }; - adapterSettings.DoesDirectoryExistSetter = (str) => { return true; }; + var adapterSettings = new TestableMSTestAdapterSettings(expectedResult) + { + ExpandEnvironmentVariablesSetter = (str) => { return str.Replace("%temp%", "C:\\foo"); }, + DoesDirectoryExistSetter = (str) => { return true; } + }; IList result = adapterSettings.GetDirectoryListWithRecursiveProperty(baseDirectory); Assert.IsNotNull(result); diff --git a/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Utilities/ns10FileUtilityTests.cs b/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Utilities/ns10FileUtilityTests.cs index 8f26814d47..8deacfb7a2 100644 --- a/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Utilities/ns10FileUtilityTests.cs +++ b/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Utilities/ns10FileUtilityTests.cs @@ -29,8 +29,10 @@ public class FileUtilityTests [TestInitialize] public void TestInit() { - this.fileUtility = new Mock(); - this.fileUtility.CallBase = true; + this.fileUtility = new Mock + { + CallBase = true + }; } [TestMethod] diff --git a/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/ns10ReflectionOperationsTests.cs b/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/ns10ReflectionOperationsTests.cs index dcff19ad57..2f99328afc 100644 --- a/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/ns10ReflectionOperationsTests.cs +++ b/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/ns10ReflectionOperationsTests.cs @@ -233,7 +233,7 @@ private string[] GetAttributeValuePairs(object[] attributes) } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] - public class DummyAAttribute : Attribute + public sealed class DummyAAttribute : Attribute { public DummyAAttribute(string foo) { @@ -244,7 +244,7 @@ public DummyAAttribute(string foo) } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)] - public class DummySingleAAttribute : Attribute + public sealed class DummySingleAAttribute : Attribute { public DummySingleAAttribute(string foo) { diff --git a/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.3/Utilities/ns13ReflectionUtilityTests.cs b/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.3/Utilities/ns13ReflectionUtilityTests.cs index b8dc9107d6..c94434308c 100644 --- a/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.3/Utilities/ns13ReflectionUtilityTests.cs +++ b/test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.3/Utilities/ns13ReflectionUtilityTests.cs @@ -261,7 +261,7 @@ public DummyAAttribute(string foo) } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)] - public class DummySingleAAttribute : Attribute + public sealed class DummySingleAAttribute : Attribute { public DummySingleAAttribute(string foo) {