Skip to content

Commit

Permalink
fix InstanceDataCollectionCollection_CopyTo by retrying on 0 values (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
smasher164 committed Jun 2, 2022
1 parent 78bdcc0 commit c835dc2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ public static void InstanceDataCollectionCollection_CopyTo()

public static InstanceDataCollectionCollection GetInstanceDataCollectionCollection()
{
PerformanceCounterCategory pcc = Helpers.RetryOnAllPlatforms(() => new PerformanceCounterCategory("Processor"));
return Helpers.RetryOnAllPlatforms(() => pcc.ReadCategory());
PerformanceCounterCategory pcc = Helpers.RetryOnAllPlatforms(() => new PerformanceCounterCategory("Processor"));
return Helpers.RetryOnAllPlatforms(() =>
{
var idcc = pcc.ReadCategory();
Assert.InRange(idcc.Values.Count, 1, int.MaxValue);
return idcc;
});
}

public static InstanceDataCollection GetInstanceDataCollection()
Expand Down

0 comments on commit c835dc2

Please sign in to comment.