Skip to content

Commit 88183f4

Browse files
authored
remove redudnant cast to IReadOnlyList and add a not null ckeck in AssemblyEnumeratorTests (#5402)
1 parent 803e1d6 commit 88183f4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/UnitTests/MSTestAdapter.UnitTests/Discovery/AssemblyEnumeratorTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void GetTypesShouldReturnSetOfDefinedTypes()
9494
// Setup mocks
9595
mockAssembly.Setup(a => a.GetTypes()).Returns(expectedTypes);
9696

97-
IReadOnlyList<Type> types = AssemblyEnumerator.GetTypes(mockAssembly.Object, string.Empty, _warnings);
97+
Type[] types = AssemblyEnumerator.GetTypes(mockAssembly.Object, string.Empty, _warnings);
9898
Verify(expectedTypes.SequenceEqual(types));
9999
}
100100

@@ -116,7 +116,7 @@ public void GetTypesShouldReturnReflectionTypeLoadExceptionTypesOnException()
116116
// Setup mocks
117117
mockAssembly.Setup(a => a.GetTypes()).Throws(new ReflectionTypeLoadException(reflectedTypes, null));
118118

119-
IReadOnlyList<Type> types = AssemblyEnumerator.GetTypes(mockAssembly.Object, string.Empty, _warnings);
119+
Type[] types = AssemblyEnumerator.GetTypes(mockAssembly.Object, string.Empty, _warnings);
120120

121121
Verify(types is not null);
122122
Verify(reflectedTypes.Equals(types));
@@ -131,7 +131,10 @@ public void GetTypesShouldLogWarningsWhenReflectionFailsWithLoaderExceptions()
131131
mockAssembly.Setup(a => a.GetTypes()).Throws(new ReflectionTypeLoadException(null, exceptions));
132132
mockAssembly.Setup(a => a.GetTypes()).Throws(new ReflectionTypeLoadException(null, exceptions));
133133

134-
IReadOnlyList<Type> types = AssemblyEnumerator.GetTypes(mockAssembly.Object, "DummyAssembly", _warnings);
134+
Type[] types = AssemblyEnumerator.GetTypes(mockAssembly.Object, "DummyAssembly", _warnings);
135+
136+
// Depending on the TFM, .NET either gives us null or empty array.
137+
Verify(types is null || types.Length == 0);
135138

136139
Verify(_warnings.Count == 1);
137140
Verify(_warnings.ToList().Contains(

0 commit comments

Comments
 (0)