public static async Task CorrectDurationForStatInAsyncFunction() { var publisher = new FakeStatsPublisher(); await publisher.Time("stat", async t => await DelayedAnswerAsync()); PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds); }
public static async Task CanRecordStatInAsyncAction() { var publisher = new FakeStatsPublisher(); await publisher.Time("statOverAsyncAction", async t => await DelayAsync()); PublisherAssertions.SingleStatNameIs(publisher, "statOverAsyncAction"); }
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"); }
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); }
public static void CanRecordStatInAction() { var publisher = new FakeStatsPublisher(); publisher.Time("statOverAction", t => Delay()); PublisherAssertions.SingleStatNameIs(publisher, "statOverAction"); PublisherAssertions.LastDurationIs(publisher, TimingConstants.DelayMilliseconds); }
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"); }
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); }