public void TimerMetric_CanCount() { timer.Value.Rate.Count.Should().Be(0); using (timer.NewContext()) { } timer.Value.Rate.Count.Should().Be(1); using (timer.NewContext()) { } timer.Value.Rate.Count.Should().Be(2); timer.Time(() => { }); timer.Value.Rate.Count.Should().Be(3); timer.Time(() => 1); timer.Value.Rate.Count.Should().Be(4); }
public void TimerCanCount() { TimerMetric timer = new TimerMetric(); timer.Value.Rate.Count.Should().Be(0); using (timer.NewContext()) { } timer.Value.Rate.Count.Should().Be(1); using (timer.NewContext()) { } timer.Value.Rate.Count.Should().Be(2); timer.Time(() => { }); timer.Value.Rate.Count.Should().Be(3); timer.Time(() => 1); timer.Value.Rate.Count.Should().Be(4); }
public void can_count() { _timer.Value.Rate.Count.Should().Be(0); using (_timer.NewContext()) { } _timer.Value.Rate.Count.Should().Be(1); using (_timer.NewContext()) { } _timer.Value.Rate.Count.Should().Be(2); _timer.Time(() => { }); _timer.Value.Rate.Count.Should().Be(3); _timer.Time(() => 1); _timer.Value.Rate.Count.Should().Be(4); }
public void TimerCountsEvenIfActionThrows() { TimerMetric timer = new TimerMetric(); Action action = () => timer.Time(() => { throw new InvalidOperationException(); }); action.ShouldThrow <InvalidOperationException>(); timer.Value.Rate.Count.Should().Be(1); }
public void TimerCountsEvenIfActionThrows() { TimerMetric timer = new TimerMetric(); Action action = () => timer.Time(() => { throw new InvalidOperationException(); }); action.ShouldThrow<InvalidOperationException>(); timer.Value.Rate.Count.Should().Be(1); }
public void Can_time_closure() { var timer = new TimerMetric(TimeUnit.Seconds, TimeUnit.Seconds); var result = timer.Time(() => { Thread.Sleep(1); return(true); }); Assert.True(result.IsStarted); Assert.True(result.IsStopped); Assert.True(result.StartedAt.HasValue); Assert.True(result.StoppedAt.HasValue); Assert.True(result); Assert.Equal(1, timer.Count); Assert.True(timer.Mean > 0); }