-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
351 additions
and
3,012 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
1,328 changes: 0 additions & 1,328 deletions
1,328
visual-studio/source/GitWebLinks/packages.lock.json
This file was deleted.
Oops, something went wrong.
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
7 changes: 3 additions & 4 deletions
7
visual-studio/tests/GitWebLinks.UnitTests/Handlers/xUnit/HandlerCustomFactAttribute.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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
using Xunit.Sdk; | ||
using Xunit.v3; | ||
|
||
namespace GitWebLinks; | ||
|
||
[XunitTestCaseDiscoverer("GitWebLinks.HandlerCustomTestCaseDiscoverer", "GitWebLinks.UnitTests")] | ||
public sealed class HandlerCustomFactAttribute : FactAttribute { | ||
} | ||
[XunitTestCaseDiscoverer(typeof(HandlerCustomTestCaseDiscoverer))] | ||
public sealed class HandlerCustomFactAttribute : FactAttribute { } |
76 changes: 39 additions & 37 deletions
76
visual-studio/tests/GitWebLinks.UnitTests/Handlers/xUnit/HandlerCustomTestCase.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 |
---|---|---|
@@ -1,63 +1,65 @@ | ||
using System.ComponentModel; | ||
using System.Text.RegularExpressions; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
using Xunit.v3; | ||
|
||
namespace GitWebLinks; | ||
|
||
public class HandlerCustomTestCase : HandlerTestCase { | ||
|
||
private string _customTestName; | ||
|
||
|
||
public HandlerCustomTestCase( | ||
IMessageSink diagnosticMessageSink, | ||
TestMethodDisplay defaultMethodDisplay, | ||
TestMethodDisplayOptions defaultMethodDisplayOptions, | ||
ITestMethod testMethod, | ||
string handlerName, | ||
string customTestName | ||
) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, handlerName, [customTestName]) { | ||
_customTestName = customTestName; | ||
} | ||
|
||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
[Obsolete("Used for deserialization only.")] | ||
public HandlerCustomTestCase() { | ||
_customTestName = ""; | ||
CustomTestName = ""; | ||
} | ||
|
||
|
||
protected override string GetDisplayName(IAttributeInfo factAttribute, string displayName) { | ||
string[] nameParts; | ||
|
||
|
||
// The display name of the underlying test case will be the | ||
// full name of the method (namespace + class + method name). | ||
// Add the handler name before the method name, and replace | ||
// the method name with the name of the custom test. | ||
nameParts = BaseDisplayName.Split('.'); | ||
nameParts[nameParts.Length - 1] = $"[{HandlerName}] {_customTestName}"; | ||
|
||
return string.Join(".", nameParts); | ||
public HandlerCustomTestCase( | ||
string handlerName, | ||
string customTestName, | ||
IXunitTestMethod testMethod, | ||
string testCaseDisplayName, | ||
string uniqueID, | ||
bool @explicit, | ||
string? skipReason = null, | ||
Type? skipType = null, | ||
string? skipUnless = null, | ||
string? skipWhen = null, | ||
Dictionary<string, HashSet<string>>? traits = null, | ||
string? sourceFilePath = null, | ||
int? sourceLineNumber = null, | ||
int? timeout = null | ||
) : base( | ||
handlerName, | ||
testMethod, | ||
testCaseDisplayName, | ||
uniqueID, | ||
@explicit, | ||
skipReason, | ||
skipType, | ||
skipUnless, | ||
skipWhen, | ||
traits, | ||
[customTestName], | ||
sourceFilePath, | ||
sourceLineNumber, | ||
timeout | ||
) { | ||
CustomTestName = customTestName; | ||
} | ||
|
||
|
||
protected override string GetUniqueID() { | ||
return $"{base.GetUniqueID()}+{Regex.Replace(_customTestName, "\\s\\.", "_")}"; | ||
} | ||
public string CustomTestName { get; set; } | ||
|
||
|
||
public override void Deserialize(IXunitSerializationInfo data) { | ||
_customTestName = data.GetValue<string>("CustomTestName"); | ||
protected override void Deserialize(IXunitSerializationInfo data) { | ||
base.Deserialize(data); | ||
CustomTestName = data.GetValue<string>(nameof(CustomTestName))!; | ||
} | ||
|
||
|
||
public override void Serialize(IXunitSerializationInfo data) { | ||
data.AddValue("CustomTestName", _customTestName); | ||
protected override void Serialize(IXunitSerializationInfo data) { | ||
base.Serialize(data); | ||
data.AddValue(nameof(CustomTestName), CustomTestName); | ||
} | ||
|
||
} |
56 changes: 33 additions & 23 deletions
56
visual-studio/tests/GitWebLinks.UnitTests/Handlers/xUnit/HandlerCustomTestCaseDiscoverer.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 |
---|---|---|
@@ -1,35 +1,45 @@ | ||
using Xunit.Abstractions; | ||
using System.Text.RegularExpressions; | ||
using Xunit.Internal; | ||
using Xunit.Sdk; | ||
using Xunit.v3; | ||
|
||
namespace GitWebLinks; | ||
|
||
public class HandlerCustomTestCaseDiscoverer : IXunitTestCaseDiscoverer { | ||
|
||
private readonly IMessageSink _diagnosticMessageSink; | ||
|
||
|
||
public HandlerCustomTestCaseDiscoverer(IMessageSink diagnosticMessageSink) { | ||
_diagnosticMessageSink = diagnosticMessageSink; | ||
} | ||
|
||
|
||
public IEnumerable<IXunitTestCase> Discover( | ||
public ValueTask<IReadOnlyCollection<IXunitTestCase>> Discover( | ||
ITestFrameworkDiscoveryOptions discoveryOptions, | ||
ITestMethod testMethod, | ||
IAttributeInfo factAttribute | ||
IXunitTestMethod testMethod, | ||
IFactAttribute factAttribute | ||
) { | ||
foreach (HandlerTestDefinition definition in TestDefinitionProvider.GetDefinitions()) { | ||
foreach (CustomTest test in definition.Tests.CreateUrl.Misc) { | ||
yield return new HandlerCustomTestCase( | ||
_diagnosticMessageSink, | ||
discoveryOptions.MethodDisplayOrDefault(), | ||
discoveryOptions.MethodDisplayOptionsOrDefault(), | ||
testMethod, | ||
#pragma warning disable IDE0008 // Use explicit type | ||
var details = TestIntrospectionHelper.GetTestCaseDetails( | ||
discoveryOptions, | ||
testMethod, | ||
factAttribute | ||
); | ||
#pragma warning restore IDE0008 // Use explicit type | ||
|
||
return new ValueTask<IReadOnlyCollection<IXunitTestCase>>( | ||
( | ||
from definition in TestDefinitionProvider.GetDefinitions() | ||
from test in definition.Tests.CreateUrl.Misc | ||
select new HandlerCustomTestCase( | ||
definition.Name, | ||
test.Name | ||
); | ||
} | ||
} | ||
test.Name, | ||
details.ResolvedTestMethod, | ||
$"[{definition.Name}] {test.Name}", | ||
$"{details.UniqueID}+{Regex.Replace($"{definition.Name}+{test.Name}", "\\s\\.", "_")}", | ||
details.Explicit, | ||
details.SkipReason, | ||
details.SkipType, | ||
details.SkipUnless, | ||
details.SkipWhen, | ||
testMethod.Traits.ToReadWrite(StringComparer.OrdinalIgnoreCase), | ||
timeout: details.Timeout | ||
) | ||
).ToList() | ||
); | ||
} | ||
|
||
} |
7 changes: 3 additions & 4 deletions
7
visual-studio/tests/GitWebLinks.UnitTests/Handlers/xUnit/HandlerFactAttribute.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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
using Xunit.Sdk; | ||
using Xunit.v3; | ||
|
||
namespace GitWebLinks; | ||
|
||
[XunitTestCaseDiscoverer("GitWebLinks.HandlerTestCaseDiscoverer", "GitWebLinks.UnitTests")] | ||
public sealed class HandlerFactAttribute : FactAttribute { | ||
} | ||
[XunitTestCaseDiscoverer(typeof(HandlerTestCaseDiscoverer))] | ||
public sealed class HandlerFactAttribute : FactAttribute { } |
14 changes: 0 additions & 14 deletions
14
visual-studio/tests/GitWebLinks.UnitTests/Handlers/xUnit/HandlerTest.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.