Пример #1
0
        public async Task CorrectDurationForStatInAsyncFunction()
        {
            var publisher = new FakeStatsPublisher();
            await publisher.Time("stat", async() => await DelayedAnswerAsync());

            PublisherAssertions.LastDurationIs(publisher, StandardDelayMillis);
        }
Пример #2
0
        public void CanRecordStatInAction()
        {
            var publisher = new FakeStatsPublisher();

            publisher.Time("statOverAction", () => Delay());

            PublisherAssertions.SingleStatNameIs(publisher, "statOverAction");
            PublisherAssertions.LastDurationIs(publisher, StandardDelayMillis);
        }
Пример #3
0
        public void CanRecordStatInFunction()
        {
            var publisher = new FakeStatsPublisher();
            var answer    = publisher.Time("statOverFunc", () => DelayedAnswer());

            Assert.That(answer, Is.EqualTo(42));
            PublisherAssertions.SingleStatNameIs(publisher, "statOverFunc");
            PublisherAssertions.LastDurationIs(publisher, StandardDelayMillis);
        }
Пример #4
0
        public async Task CanRecordStatAsync()
        {
            var publisher = new FakeStatsPublisher();

            using (publisher.StartTimer("statWithAsync"))
            {
                await DelayAsync();
            }

            PublisherAssertions.SingleStatNameIs(publisher, "statWithAsync");
            PublisherAssertions.LastDurationIs(publisher, StandardDelayMillis);
        }
Пример #5
0
        public void CanRecordStat()
        {
            var publisher = new FakeStatsPublisher();

            using (publisher.StartTimer("stat"))
            {
                Delay();
            }

            PublisherAssertions.SingleStatNameIs(publisher, "stat");
            PublisherAssertions.LastDurationIs(publisher, StandardDelayMillis);
        }
Пример #6
0
        public async Task CanRecordTwoStatsAsync()
        {
            var publisher = new FakeStatsPublisher();

            using (publisher.StartTimer("stat1"))
            {
                await DelayAsync();
            }

            using (publisher.StartTimer("stat2"))
            {
                await DelayAsync();
            }

            Assert.That(publisher.CallCount, Is.EqualTo(2));
            Assert.That(publisher.BucketNames, Is.EquivalentTo(new List <string> {
                "stat1", "stat2"
            }));
            PublisherAssertions.LastDurationIs(publisher, StandardDelayMillis);
        }