[EventSource(Name = "SimpleEventSource")]
private sealed class SimpleEventSource : EventSource
{
- private object _failureCounter;
+ private object _mockedCounter;
- public SimpleEventSource(Func<double> getFailureCount, Type IncrementingPollingCounterType)
+ public SimpleEventSource(Func<double> getMockedCount, Type IncrementingPollingCounterType)
{
- _failureCounter = Activator.CreateInstance(IncrementingPollingCounterType, "failureCount", this, getFailureCount);
+ _mockedCounter = Activator.CreateInstance(IncrementingPollingCounterType, "failureCount", this, getMockedCount);
}
}
}
- public static int failureCountCalled = 0;
+ public static int mockedCountCalled = 0;
- public static double getFailureCount()
+ public static double getMockedCount()
{
- failureCountCalled++;
- return failureCountCalled;
+ mockedCountCalled++;
+ return mockedCountCalled;
}
public static int Main(string[] args)
{
return 1;
}
- SimpleEventSource eventSource = new SimpleEventSource(getFailureCount, IncrementingPollingCounterType);
+ SimpleEventSource eventSource = new SimpleEventSource(getMockedCount, IncrementingPollingCounterType);
// Want to sleep for 5000 ms to get some counters piling up.
Thread.Sleep(5000);
- if (!myListener.Failed && failureCountCalled > 0)
+ if (!myListener.Failed && mockedCountCalled > 0)
{
Console.WriteLine("Test Passed");
return 100;
private object _failureCounter;
private object _successCounter;
- public SimpleEventSource(Func<double> getFailureCount, Func<double> getSuccessCount, Type PollingCounterType)
+ public SimpleEventSource(Func<double> getMockedCount, Func<double> getSuccessCount, Type PollingCounterType)
{
_failureCounter = Activator.CreateInstance(PollingCounterType, "failureCount", this, getSuccessCount);
- _successCounter = Activator.CreateInstance(PollingCounterType, "successCount", this, getFailureCount);
+ _successCounter = Activator.CreateInstance(PollingCounterType, "successCount", this, getMockedCount);
}
}
}
else if (name.Equals("successCount"))
{
- if (Int32.Parse(mean) != failureCountCalled)
+ if (Int32.Parse(mean) != mockedCountCalled)
{
- Console.WriteLine($"Mean is not what we expected: {mean} vs {failureCountCalled}");
+ Console.WriteLine($"Mean is not what we expected: {mean} vs {mockedCountCalled}");
}
}
}
- public static int failureCountCalled = 0;
+ public static int mockedCountCalled = 0;
public static int successCountCalled = 0;
- public static double getFailureCount()
+ public static double getMockedCount()
{
- failureCountCalled++;
- return failureCountCalled;
+ mockedCountCalled++;
+ return mockedCountCalled;
}
public static double getSuccessCount()
return 1;
}
- SimpleEventSource eventSource = new SimpleEventSource(getFailureCount, getSuccessCount, PollingCounterType);
+ SimpleEventSource eventSource = new SimpleEventSource(getMockedCount, getSuccessCount, PollingCounterType);
// Want to sleep for 5000 ms to get some counters piling up.
Thread.Sleep(5000);
- if (myListener.FailureEventCount > 0 && myListener.SuccessEventCount > 0 && !myListener.Failed && (failureCountCalled > 0 && successCountCalled > 0))
+ if (myListener.FailureEventCount > 0 && myListener.SuccessEventCount > 0 && !myListener.Failed && (mockedCountCalled > 0 && successCountCalled > 0))
{
Console.WriteLine("Test Passed");
return 100;