コード例 #1
0
        public void WarewolfServicesNotFoundCounter_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 WarewolfServicesNotFoundCounter(performanceCounterFactory);

            counter.Setup();

            mockPerformanceCounterFactory.Verify(o => o.New(GlobalConstants.Warewolf, CounterName, GlobalConstants.GlobalCounterName), Times.Once);
        }
コード例 #2
0
        public void WarewolfServicesNotFoundCounter_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 WarewolfServicesNotFoundCounter(performanceCounterFactory);

            counter.Setup();
            counter.Reset();

            mockPerformanceCounterFactory.Verify();
            mockCounter.VerifySet(o => o.RawValue = 0, Times.Once);
        }
コード例 #3
0
        public void WarewolfServicesNotFoundCounter_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 WarewolfServicesNotFoundCounter(performanceCounterFactory);

            counter.Setup();
            counter.IncrementBy(1234);

            mockPerformanceCounterFactory.Verify();
            mockCounter.Verify(o => o.IncrementBy(1234), Times.Once);
        }
コード例 #4
0
        public void WarewolfServicesNotFoundCounter_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 WarewolfServicesNotFoundCounter(performanceCounterFactory))
            {
                counter.Setup();
                counter.Decrement();

                mockPerformanceCounterFactory.Verify();
                mockCounter.Verify(o => o.Decrement(), Times.Once);
            }
        }