Skip to content

Commit

Permalink
#724 comments fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Haplois committed Sep 6, 2021
1 parent a58d335 commit 0e10515
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
.vs/
.vscode/
*.cache
.idea/

# Build results
[Bb]in/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ internal TestAssemblySettings GetSettings(string source)
testAssemblySettings.CanParallelizeAssembly = !this.reflectHelper.IsDoNotParallelizeSet(testAssembly);

var classCleanupSequencingAttribute = this.reflectHelper.GetClassCleanupAttribute(testAssembly);

if (classCleanupSequencingAttribute != null)
{
testAssemblySettings.ClassCleanupLifecycle = classCleanupSequencingAttribute.LifecyclePosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ internal static string GetTestName(this TestCase testCase, string testClassName)
var name = fullyQualifiedName.StartsWith($"{testClassName}.")
? fullyQualifiedName.Remove(0, $"{testClassName}.".Length)
: fullyQualifiedName;

return name;
}

Expand Down
12 changes: 9 additions & 3 deletions src/Adapter/MSTest.CoreAdapter/MSTestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private static MSTestSettings ToSettings(XmlReader reader)
case "CLASSCLEANUPLIFECYCLE":
{
var value = reader.ReadInnerXml();
if (Enum.TryParse(value, out ClassCleanupLifecycle lifecycle))
if (TryParseEnum(value, out ClassCleanupLifecycle lifecycle))
{
settings.ClassCleanupLifecycle = lifecycle;
}
Expand All @@ -374,7 +374,7 @@ private static MSTestSettings ToSettings(XmlReader reader)
throw new AdapterSettingsException(
string.Format(
CultureInfo.CurrentCulture,
Resource.InvalidParallelScopeValue,
Resource.InvalidClassCleanupLifecycleValue,
value,
string.Join(", ", Enum.GetNames(typeof(ClassCleanupLifecycle)))));
}
Expand Down Expand Up @@ -516,7 +516,7 @@ private static void SetParallelSettings(XmlReader reader, MSTestSettings setting
case "SCOPE":
{
var value = reader.ReadInnerXml();
if (Enum.TryParse(value, out ExecutionScope scope))
if (TryParseEnum(value, out ExecutionScope scope))
{
settings.ParallelizationScope = scope;
}
Expand Down Expand Up @@ -558,6 +558,12 @@ private static void SetParallelSettings(XmlReader reader, MSTestSettings setting
}
}

private static bool TryParseEnum<T>(string value, out T result)
where T : struct, Enum
{
return Enum.TryParse<T>(value, true, out result) && Enum.IsDefined(typeof(T), result);
}

private static void SetGlobalSettings(string runsettingsXml, MSTestSettings settings)
{
var runconfigElement = XDocument.Parse(runsettingsXml)?.Element("RunSettings")?.Element("RunConfiguration");
Expand Down
4 changes: 2 additions & 2 deletions src/TestFramework/Extension.UWP/Extension.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<DefaultLanguage>en-US</DefaultLanguage>
<RuntimeIdentifiers>win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot</RuntimeIdentifiers>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>15</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Microsoft.VisualStudio.TestTools.UnitTesting
{
/// <summary>
/// Where during test lifecycle should ClassCleanup happen
/// When to run ClassCleanup during test execution
/// </summary>
public enum ClassCleanupLifecycle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting
using System;

/// <summary>
/// Specification for parallelization level for a test run.
/// Specification for when to run class cleanup methods.
/// </summary>
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class ClassCleanupSequencingAttribute : Attribute
Expand All @@ -22,7 +22,7 @@ public ClassCleanupSequencingAttribute()
}

/// <summary>
/// Gets or sets the number of workers to be used for the parallel run.
/// Gets or sets when to run class cleanup methods.
/// </summary>
public ClassCleanupLifecycle LifecyclePosition
{
Expand Down

0 comments on commit 0e10515

Please sign in to comment.