public void WarewolfNumberOfAuthErrors_Setup_CreatesCounter() { var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>(); var mockCounter = new Mock <IWarewolfPerformanceCounter>(); mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, CounterName, GlobalConstants.GlobalCounterName)).Returns(mockCounter.Object); var performanceCounterFactory = mockPerformanceCounterFactory.Object; IPerformanceCounter counter = new WarewolfNumberOfAuthErrors(performanceCounterFactory); counter.Setup(); mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, CounterName, GlobalConstants.GlobalCounterName), Times.Once); }
public void WarewolfNumberOfAuthErrors_Construct() { var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>(); var performanceCounterFactory = mockPerformanceCounterFactory.Object; using (IPerformanceCounter counter = new WarewolfNumberOfAuthErrors(performanceCounterFactory)) { Assert.IsTrue(counter.IsActive); Assert.AreEqual(WarewolfPerfCounterType.NotAuthorisedErrors, counter.PerfCounterType); Assert.AreEqual(GlobalConstants.Warewolf, counter.Category); Assert.AreEqual(CounterName, counter.Name); } }
public void WarewolfNumberOfAuthErrors_IncrementBy_CallsUnderlyingCounter() { var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>(); var mockCounter = new Mock <IWarewolfPerformanceCounter>(); mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, CounterName, GlobalConstants.GlobalCounterName)).Returns(mockCounter.Object).Verifiable(); var performanceCounterFactory = mockPerformanceCounterFactory.Object; IPerformanceCounter counter = new WarewolfNumberOfAuthErrors(performanceCounterFactory); counter.Setup(); counter.IncrementBy(1234); mockPerformanceCounterFactory.Verify(); mockCounter.Verify(o => o.IncrementBy(1234), Times.Once); }
public void WarewolfNumberOfAuthErrors_Reset_ClearsCounter() { var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>(); var mockCounter = new Mock <IWarewolfPerformanceCounter>(); mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, CounterName, GlobalConstants.GlobalCounterName)).Returns(mockCounter.Object).Verifiable(); var performanceCounterFactory = mockPerformanceCounterFactory.Object; IPerformanceCounter counter = new WarewolfNumberOfAuthErrors(performanceCounterFactory); counter.Setup(); counter.Reset(); mockPerformanceCounterFactory.Verify(); mockCounter.VerifySet(o => o.RawValue = 0, Times.Once); }
public void WarewolfNumberOfAuthErrors_CreationData_Valid() { var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>(); var performanceCounterFactory = mockPerformanceCounterFactory.Object; IPerformanceCounter counter = new WarewolfNumberOfAuthErrors(performanceCounterFactory); var data = counter.CreationData(); Assert.AreEqual(1, data.Count()); var dataItem = counter.CreationData().First(); Assert.AreEqual(CounterName, dataItem.CounterHelp); Assert.AreEqual(CounterName, dataItem.CounterName); Assert.AreEqual(PerformanceCounterType.NumberOfItems32, dataItem.CounterType); }
public void WarewolfNumberOfAuthErrors_Decrement_CallsUnderlyingCounter() { var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>(); var mockCounter = new Mock <IWarewolfPerformanceCounter>(); mockCounter.SetupGet(o => o.RawValue).Returns(1); mockPerformanceCounterFactory.Setup(o => o.New(GlobalConstants.Warewolf, CounterName, GlobalConstants.GlobalCounterName)).Returns(mockCounter.Object).Verifiable(); var performanceCounterFactory = mockPerformanceCounterFactory.Object; using (IPerformanceCounter counter = new WarewolfNumberOfAuthErrors(performanceCounterFactory)) { counter.Setup(); counter.Decrement(); mockPerformanceCounterFactory.Verify(); mockCounter.Verify(o => o.Decrement(), Times.Once); } }