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

            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
示例#2
0
        public static async Task CanRecordStatInAsyncAction()
        {
            var publisher = new FakeStatsPublisher();
            await publisher.Time("statOverAsyncAction", async t => await DelayAsync());

            PublisherAssertions.SingleStatNameIs(publisher, "statOverAsyncAction");
        }
示例#3
0
        public static async Task CanRecordStatInAsyncFunction()
        {
            var publisher = new FakeStatsPublisher();
            var answer    = await publisher.Time("statOverAsyncFunc", async t => await DelayedAnswerAsync());

            answer.ShouldBe(42);
            PublisherAssertions.SingleStatNameIs(publisher, "statOverAsyncFunc");
        }
示例#4
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);
        }
示例#5
0
        public static void CanRecordStatInAction()
        {
            var publisher = new FakeStatsPublisher();

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

            PublisherAssertions.SingleStatNameIs(publisher, "statOverAction");
            PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds);
        }
示例#6
0
        public static async Task CanChangeStatNameInAsyncFunction()
        {
            var publisher = new FakeStatsPublisher();
            await publisher.Time("defaultName", async t =>
            {
                var result = await DelayedAnswerAsync();
                t.StatName = "afterTheAwait";
                return(result);
            });

            PublisherAssertions.SingleStatNameIs(publisher, "afterTheAwait");
        }
示例#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);
        }