Beispiel #1
0
        public void TestInitialize()
        {
            this.throttleAllContainer = new DiagnoisticsEventThrottlingMock(
                throttleAll: true,
                signalJustExceeded: true,
                sampleCounters: new Dictionary <int, DiagnoisticsEventCounters>());

            this.notThrottleContainer = new DiagnoisticsEventThrottlingMock(
                throttleAll: false,
                signalJustExceeded: false,
                sampleCounters: new Dictionary <int, DiagnoisticsEventCounters>());

            this.scheduler = new DiagnoisticsEventThrottlingSchedulerMock();

            this.sender = new DiagnosticsEventCollectingMock();

            this.throttleFirstCallManager = new DiagnoisticsEventThrottlingManager <DiagnoisticsEventThrottlingMock>(
                this.throttleAllContainer,
                this.scheduler,
                SampleIntervalInMinutes);

            this.notThrottleManager = new DiagnoisticsEventThrottlingManager <DiagnoisticsEventThrottlingMock>(
                this.notThrottleContainer,
                this.scheduler,
                SampleIntervalInMinutes);

            this.listener = new DiagnosticsListener(new List <IDiagnosticsSender> {
                this.sender
            });

            this.listener.LogLevel = EventLevel.Verbose;
        }
        public void TestActionRegisteredAfterInitialization()
        {
            var manager = new DiagnoisticsEventThrottlingManager <DiagnoisticsEventThrottlingMock>(
                this.container,
                this.scheduler,
                SampleIntervalInMinutes);

            Assert.AreEqual(1, this.scheduler.Items.Count, "Unexpected count of registered actions");

            var item = this.scheduler.Items.First();

            Assert.IsNotNull(item.Action, "Action is not set");

            Assert.AreEqual(SampleIntervalInMiliseconds, (uint)item.Interval, "Unexpected interval value");
        }
        public DiagnoisticsEventThrottlingManagerTest()
        {
            this.throttleFirstCallManager = new DiagnoisticsEventThrottlingManager <DiagnoisticsEventThrottlingMock>(
                this.throttleAllContainer,
                this.scheduler,
                SampleIntervalInMinutes);

            this.notThrottleManager = new DiagnoisticsEventThrottlingManager <DiagnoisticsEventThrottlingMock>(
                this.notThrottleContainer,
                this.scheduler,
                SampleIntervalInMinutes);

            this.listener = new DiagnosticsListener(new List <IDiagnosticsSender> {
                this.sender
            });

            this.listener.LogLevel = EventLevel.Verbose;
        }
Beispiel #4
0
        public void TestActionRegisteredAfterInitialization()
        {
            var manager = new DiagnoisticsEventThrottlingManager <DiagnoisticsEventThrottlingMock>(
                this.container,
                this.scheduler,
                SampleIntervalInMinutes);

            Assert.AreEqual(1, this.scheduler.Items.Count, "Unexpected count of registered actions");

            var item = this.scheduler.Items.First();

            Assert.IsNotNull(item.Action, "Action is not set");

#if NET40
            Assert.AreEqual(
                manager.GetType(),
                item.Action.Method.DeclaringType,
                "Unexpected type of method binded with action");
#endif

            Assert.AreEqual(SampleIntervalInMiliseconds, (uint)item.Interval, "Unexpected interval value");
        }