Skip to content

Commit c835dc2

Browse files
authored
fix InstanceDataCollectionCollection_CopyTo by retrying on 0 values (#70119)
* fix InstanceDataCollectionCollection_CopyTo by retrying on 0 values Previously, when pcc.ReadCategory() returned 0 values, we did not retry, which broke the test that asserted its length > 0. This time, we retry when there are 0 values, by triggering the RetryHelper's exception handler. Fixes #68291 * add ZeroDataException * Revert "add ZeroDataException" This reverts commit 43ba3ad. * throw xUnitException instead of making a custom one * no need for if statement
1 parent 78bdcc0 commit c835dc2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/libraries/System.Diagnostics.PerformanceCounter/tests/InstanceDataTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ public static void InstanceDataCollectionCollection_CopyTo()
124124

125125
public static InstanceDataCollectionCollection GetInstanceDataCollectionCollection()
126126
{
127-
PerformanceCounterCategory pcc = Helpers.RetryOnAllPlatforms(() => new PerformanceCounterCategory("Processor"));
128-
return Helpers.RetryOnAllPlatforms(() => pcc.ReadCategory());
127+
PerformanceCounterCategory pcc = Helpers.RetryOnAllPlatforms(() => new PerformanceCounterCategory("Processor"));
128+
return Helpers.RetryOnAllPlatforms(() =>
129+
{
130+
var idcc = pcc.ReadCategory();
131+
Assert.InRange(idcc.Values.Count, 1, int.MaxValue);
132+
return idcc;
133+
});
129134
}
130135

131136
public static InstanceDataCollection GetInstanceDataCollection()

0 commit comments

Comments
 (0)