Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
            }
        }