Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
More logging, change test
Browse files Browse the repository at this point in the history
  • Loading branch information
michellemcdaniel committed Oct 31, 2017
1 parent 2746dc3 commit 7e7f26e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public static void PerformanceCounterCategory_ReadCategory()

InstanceDataCollectionCollection idColCol = pcc.ReadCategory();

Assert.True(idColCol.Count > 0);
Assert.NotNull(idColCol);
}

[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndCanWriteToPerfCounters))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ public static void PerformanceCounter_CreateCounter_ProcessorCounter()
public static void PerformanceCounter_CreateCounter_MultiInstanceReadOnly()
{
var name = nameof(PerformanceCounter_CreateCounter_MultiInstanceReadOnly) + "_Counter";
var category = name + "_Category";
var instance = name + "_Instance";

CreateCategory(name, PerformanceCounterCategoryType.MultiInstance);
var category = CreateCategory(name, PerformanceCounterCategoryType.MultiInstance);

Console.WriteLine("{0} exists: {1}", category, PerformanceCounterCategory.Exists(category));

using (PerformanceCounter counterSample = new PerformanceCounter(category, name, instance))
{
Expand All @@ -73,9 +74,8 @@ public static void PerformanceCounter_CreateCounter_MultiInstanceReadOnly()
public static void PerformanceCounter_CreateCounter_SetReadOnly()
{
var name = nameof(PerformanceCounter_CreateCounter_SetReadOnly) + "_Counter";
var category = name + "_Category";

CreateCategory(name, PerformanceCounterCategoryType.SingleInstance);
var category = CreateCategory(name, PerformanceCounterCategoryType.SingleInstance);

using (PerformanceCounter counterSample = new PerformanceCounter(category, name))
{
Expand Down Expand Up @@ -276,10 +276,9 @@ public static void PerformanceCounter_RemoveInstance()
public static void PerformanceCounter_NextSample_MultiInstance()
{
var name = nameof(PerformanceCounter_NextSample_MultiInstance) + "_Counter";
var category = name + "_Category";
var instance = name + "_Instance";

CreateCategory(name, PerformanceCounterCategoryType.MultiInstance);
var category = CreateCategory(name, PerformanceCounterCategoryType.MultiInstance);

using (PerformanceCounter counterSample = new PerformanceCounter(category, name, instance, false))
{
Expand All @@ -293,16 +292,14 @@ public static void PerformanceCounter_NextSample_MultiInstance()

public static PerformanceCounter CreateCounterWithCategory(string name, bool readOnly, PerformanceCounterCategoryType categoryType )
{
var category = name + "_Category";

CreateCategory(name, categoryType);
var category = CreateCategory(name, categoryType);

PerformanceCounter counterSample = new PerformanceCounter(category, name, readOnly);

return counterSample;
}

public static void CreateCategory(string name, PerformanceCounterCategoryType categoryType)
public static string CreateCategory(string name, PerformanceCounterCategoryType categoryType)
{
var category = name + "_Category";

Expand All @@ -318,6 +315,7 @@ public static void CreateCategory(string name, PerformanceCounterCategoryType ca
}

Console.WriteLine("PerformanceCounterTests: {0} exists: {1}; tries: {2}", category, PerformanceCounterCategory.Exists(category), tries);
return category;
}

public static void DeleteCategory(string name)
Expand Down

0 comments on commit 7e7f26e

Please sign in to comment.