Esempio n. 1
0
        public static async Task CorrectDurationForStatInAsyncFunction()
        {
            var publisher = new FakeStatsPublisher();
            await publisher.Time("stat", async t => await DelayedAnswerAsync());

            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
Esempio n. 2
0
        public static void CanRecordStatInFunction()
        {
            var publisher = new FakeStatsPublisher();
            var answer    = publisher.Time("statOverFunc", t => DelayedAnswer());

            answer.ShouldBe(42);
            PublisherAssertions.SingleStatNameIs(publisher, "statOverFunc");
            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
Esempio n. 3
0
        public static void CanRecordStatInAction()
        {
            var publisher = new FakeStatsPublisher();

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

            PublisherAssertions.SingleStatNameIs(publisher, "statOverAction");
            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
Esempio n. 4
0
        public static async Task CanRecordStatAsync()
        {
            var publisher = new FakeStatsPublisher();

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

            PublisherAssertions.SingleStatNameIs(publisher, "statWithAsync");
            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
Esempio n. 5
0
        public static void CanRecordStat()
        {
            var publisher = new FakeStatsPublisher();

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

            PublisherAssertions.SingleStatNameIs(publisher, "stat");
            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
Esempio n. 6
0
        public static void CanChangeStatName()
        {
            var publisher = new FakeStatsPublisher();

            using (var timer = publisher.StartTimer("defaultName"))
            {
                Delay();
                timer.StatName = "otherStat";
            }

            PublisherAssertions.SingleStatNameIs(publisher, "otherStat");
            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
Esempio n. 7
0
        public static void CanChangeStatNameInAction()
        {
            var publisher = new FakeStatsPublisher();

            publisher.Time("defaultName", t =>
            {
                Delay();
                t.StatName = "otherStat";
            });

            PublisherAssertions.SingleStatNameIs(publisher, "otherStat");
            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
Esempio n. 8
0
        public static async Task CanRecordTwoStatsAsync()
        {
            var publisher = new FakeStatsPublisher();

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

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

            publisher.CallCount.ShouldBe(2);
            publisher.BucketNames.ShouldBe(new[] { "stat1", "stat2" });
            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }