コード例 #1
0
        public void It_should_report_uptime()
        {
            var statCollector = new InMemoryStatCollector();
            ((IStartable)statCollector).Start();

            Thread.Sleep(100);

            var stats = statCollector.GetStats();
            Assert.That(stats.Uptime, Is.GreaterThan(new TimeSpan(0, 0, 0, 0, 90)));
        }
コード例 #2
0
        public void It_should_report_num_errors()
        {
            var statCollector = new InMemoryStatCollector();

            var stats = statCollector.GetStats();
            Assert.That(stats.NumErrors, Is.EqualTo(0));

            statCollector.IncrementErrors(2);
            statCollector.IncrementErrors(4);

            stats = statCollector.GetStats();
            Assert.That(stats.NumErrors, Is.EqualTo(6));
        }
コード例 #3
0
        public void It_should_report_average_time_per_request_handled()
        {
            var statCollector = new InMemoryStatCollector();

            var stats = statCollector.GetStats();
            Assert.That(stats.NumRequestsHandled, Is.EqualTo(0));

            statCollector.IncrementRequestsHandled(3, new TimeSpan(0, 0, 0, 0, 200));
            statCollector.IncrementRequestsHandled(2, new TimeSpan(0, 0, 0, 0, 500));

            stats = statCollector.GetStats();
            Assert.That(stats.AverageTimePerRequestHandled, Is.EqualTo(new TimeSpan(0, 0, 0, 0, 320)));
        }
コード例 #4
0
        public void It_should_report_num_requests_handled()
        {
            var statCollector = new InMemoryStatCollector();

            var stats = statCollector.GetStats();
            Assert.That(stats.NumRequestsHandled, Is.EqualTo(0));

            statCollector.IncrementRequestsHandled(3, new TimeSpan(0, 0, 0, 0, 200));
            statCollector.IncrementRequestsHandled(2, new TimeSpan(0, 0, 0, 0, 500));

            stats = statCollector.GetStats();
            Assert.That(stats.NumRequestsHandled, Is.EqualTo(5));
        }
コード例 #5
0
        public void It_should_report_error_rate()
        {
            var statCollector = new InMemoryStatCollector();

            var stats = statCollector.GetStats();
            Assert.That(stats.ErrorRate, Is.EqualTo(0));

            statCollector.IncrementErrors(5);
            statCollector.IncrementRequestsHandled(15, TimeSpan.Zero);

            stats = statCollector.GetStats();
            Assert.That(stats.ErrorRate, Is.EqualTo(25m));
        }