コード例 #1
0
        public void GetIntervals_When_one_interval_is_not_disposed_It_returns_empty()
        {
            var tracker = new IntervalTracker("Activity");

            _ = tracker.Start("foo");
            Assert.Equal(0, tracker.GetIntervals().Count());
        }
コード例 #2
0
        public void GetIntervals_WhenNoIntervalsAreCaptured_ReturnsEmpty()
        {
            // Setup
            var tracker = new IntervalTracker();

            // Act - do nothing

            // Assert
            Assert.Equal(0, tracker.GetIntervals().Count());
        }
コード例 #3
0
        public void GetIntervals_WhenNoEndIntervalMeasureIsCalled_ReturnsEmpty()
        {
            // Setup
            var tracker = new IntervalTracker();

            // Act - do nothing
            tracker.StartIntervalMeasure();
            tracker.StartIntervalMeasure();
            tracker.StartIntervalMeasure();
            // Assert
            Assert.Equal(0, tracker.GetIntervals().Count());
        }
コード例 #4
0
        public void GetIntervals_WhenStartIntervalIsNotCalled_IntervalsAreEmpty()
        {
            // Setup
            var tracker = new IntervalTracker();

            // Act - do nothing
            tracker.EndIntervalMeasure("one");
            tracker.EndIntervalMeasure("two");
            // Assert

            var allTimings = tracker.GetIntervals().ToList();

            Assert.Equal(2, allTimings.Count);
            Assert.True(allTimings.All(e => e.Item2.Equals(0)));
        }
コード例 #5
0
        public void IntervalTracker_All_properly_disposed_intervals_are_captured()
        {
            var tracker = new IntervalTracker("Activity");

            using (tracker.Start("first"))
            {
            }

            using (tracker.Start("second"))
            {
            }

            using (tracker.Start("third"))
            {
            }

            var allTimings = tracker.GetIntervals().ToList();

            Assert.Equal(3, allTimings.Count);
            Assert.True(allTimings.Any(e => e.Item1.Equals("first")));
            Assert.True(allTimings.Any(e => e.Item1.Equals("second")));
            Assert.True(allTimings.Any(e => e.Item1.Equals("third")));
        }
コード例 #6
0
        public void IntervalTracker_AllIntervalsAreCaptured()
        {
            // Setup
            var tracker = new IntervalTracker();

            // Act
            tracker.StartIntervalMeasure();
            tracker.EndIntervalMeasure("first");

            tracker.StartIntervalMeasure();
            tracker.EndIntervalMeasure("second");

            tracker.StartIntervalMeasure();
            tracker.EndIntervalMeasure("third");

            // Assert

            var allTimings = tracker.GetIntervals().ToList();

            Assert.Equal(3, allTimings.Count);
            Assert.True(allTimings.Any(e => e.Item1.Equals("first")));
            Assert.True(allTimings.Any(e => e.Item1.Equals("second")));
            Assert.True(allTimings.Any(e => e.Item1.Equals("third")));
        }
コード例 #7
0
        public void GetIntervals_When_no_intervals_are_captured_It_returns_empty()
        {
            var tracker = new IntervalTracker("Activity");

            Assert.Equal(0, tracker.GetIntervals().Count());
        }