public void WarewolfRequestsPerSecondPerformanceCounterByResource_Setup_CreatesCounter() { var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>(); var mockCounter = new Mock <IWarewolfPerformanceCounter>(); mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.WarewolfServices, CounterName, GlobalConstants.GlobalCounterName)).Returns(mockCounter.Object); var performanceCounterFactory = mockPerformanceCounterFactory.Object; IPerformanceCounter counter = new WarewolfRequestsPerSecondPerformanceCounterByResource(_resourceGuid, _categoryInstanceName, performanceCounterFactory); counter.Setup(); mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.WarewolfServices, CounterName, GlobalConstants.GlobalCounterName), Times.Once); }
public void WarewolfRequestsPerSecondPerformanceCounterByResource_IncrementBy_CallsUnderlyingCounter() { var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>(); var mockCounter = new Mock <IWarewolfPerformanceCounter>(); mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.WarewolfServices, CounterName, GlobalConstants.GlobalCounterName)).Returns(mockCounter.Object).Verifiable(); var performanceCounterFactory = mockPerformanceCounterFactory.Object; IPerformanceCounter counter = new WarewolfRequestsPerSecondPerformanceCounterByResource(_resourceGuid, _categoryInstanceName, performanceCounterFactory); counter.Setup(); counter.IncrementBy(1234); mockPerformanceCounterFactory.Verify(); mockCounter.Verify(o => o.IncrementBy(1234), Times.Once); }