Skip to content

Commit 708f3ff

Browse files
undo-a-rino
1 parent 4288388 commit 708f3ff

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Source/Machine.VSTestAdapter/Discovery/BuiltIn/TestDiscoverer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ private IEnumerable<MSpecTestCase> CreateTestCase(Context context, string assemb
5757
testCase.LineNumber = locationInfo.LineNumber;
5858
}
5959

60-
if (spec.GetType().Name == "BehaviorSpecification")
61-
testCase.BehaviorFieldName = GetBehaviorFieldName(spec);
60+
if (spec is BehaviorSpecification behaviorSpec)
61+
testCase.BehaviorFieldName = GetBehaviorFieldName(behaviorSpec);
6262

6363
if (context.Tags != null)
6464
testCase.Tags = context.Tags.Select(tag => tag.Name).ToArray();
@@ -70,7 +70,7 @@ private IEnumerable<MSpecTestCase> CreateTestCase(Context context, string assemb
7070
}
7171
}
7272

73-
private string GetBehaviorFieldName(Specification specification)
73+
private string GetBehaviorFieldName(BehaviorSpecification specification)
7474
{
7575
if (behaviorProperty?.GetValue(specification) is FieldInfo field)
7676
return field.Name;

Source/Machine.VSTestAdapter/Execution/TestExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void RunTestsInAssembly(string pathToAssembly, IEnumerable<VisualStudioTe
7373

7474
Specification specification = context.Specifications.SingleOrDefault(spec => spec.FieldInfo.Name.Equals(test.FieldName, StringComparison.Ordinal));
7575

76-
if (specification?.GetType().Name == "BehaviorSpecification")
76+
if (specification is BehaviorSpecification)
7777
{
7878
// MSpec doesn't expose any way to run an an "It" coming from a "[Behavior]", so we have to do some trickery
7979
VisualStudioTestIdentifier listenFor = specification.ToVisualStudioTestIdentifier(context);

0 commit comments

Comments
 (0)