-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ManagedNameHelper to support namespaceless methods.
- Loading branch information
Showing
5 changed files
with
177 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...TestPlatform.AdapterUtilities.UnitTests/ManagedNameUtilities/ManagedNameGeneratorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities.UnitTests; | ||
|
||
[TestClass] | ||
public class ManagedNameGeneratorTests | ||
{ | ||
[TestMethod] | ||
public void NamespacelessClassMembersShouldNotReportANamespace() | ||
{ | ||
// Arrange | ||
var methodBase = typeof(global::NamespacelessClass).GetMethod("Method0")!; | ||
|
||
// Act | ||
ManagedNameHelper.GetManagedName(methodBase, out var managedTypeName, out var managedMethodName); | ||
|
||
// Assert | ||
Assert.AreEqual("NamespacelessClass", managedTypeName); | ||
Assert.AreEqual("Method0", managedMethodName); | ||
} | ||
|
||
[TestMethod] | ||
public void NamespacelessInnerClassMembersShouldNotReportANamespace() | ||
{ | ||
// Arrange | ||
var methodBase = typeof(global::NamespacelessClass.Inner).GetMethod("Method0")!; | ||
|
||
// Act | ||
ManagedNameHelper.GetManagedName(methodBase, out var managedTypeName, out var managedMethodName); | ||
|
||
// Assert | ||
Assert.AreEqual("NamespacelessClass+Inner", managedTypeName); | ||
Assert.AreEqual("Method0", managedMethodName); | ||
} | ||
|
||
[TestMethod] | ||
public void NamespacelessClassMembersShouldNotReportANamespaceInHierarchy() | ||
{ | ||
// Arrange | ||
var methodBase = typeof(global::NamespacelessClass).GetMethod("Method0")!; | ||
|
||
// Act | ||
ManagedNameHelper.GetManagedName(methodBase, out var managedTypeName, out var managedMethodName, out var hierarchyValues); | ||
|
||
// Assert | ||
Assert.AreEqual("NamespacelessClass", managedTypeName); | ||
Assert.AreEqual("Method0", managedMethodName); | ||
Assert.IsNull(hierarchyValues[HierarchyConstants.Levels.NamespaceIndex]); | ||
} | ||
|
||
[TestMethod] | ||
public void NamespacelessInnerClassMembersShouldNotReportANamespaceInHierarchy() | ||
{ | ||
// Arrange | ||
var methodBase = typeof(global::NamespacelessClass.Inner).GetMethod("Method0")!; | ||
|
||
// Act | ||
ManagedNameHelper.GetManagedName(methodBase, out var managedTypeName, out var managedMethodName, out var hierarchyValues); | ||
|
||
// Assert | ||
Assert.AreEqual("NamespacelessClass+Inner", managedTypeName); | ||
Assert.AreEqual("Method0", managedMethodName); | ||
Assert.IsNull(hierarchyValues[HierarchyConstants.Levels.NamespaceIndex]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters